Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6997385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:16:37+00:00 2026-05-27T20:16:37+00:00

This is a pretty strange issue so bear with me. I have a stored

  • 0

This is a pretty strange issue so bear with me. I have a stored proc that does some heavy duty processing. When it runs well it usually takes a few minutes depending on server load, but occasionally it appears to get stuck.

I have looked at the results of sp_who2 and what I see is that the process is not blocked, it’s still listed as ‘RUNNABLE’, but the value in disk IO stays the same. Once the process gets in this state it never finishes. If I kill the process and re-execute the stored proc, I usually get the same result.

Sometimes re-executing the stored proc works, but increasingly I end up having to restart SQL Server. Not ideal… After restart the stored proc executes as expected. Has anyone even hit a problem like this? Any advice would be greatly appreciated.

Some more context. The stored proc I am executing looks something like this:

delete
from table1

insert into table1
select columns
from 
(
    select columns
    from giant_table_1 WITH (NOLOCK)
    where condition
    group by columns

    UNION

    select columns
    from giant_table_2 WITH (NOLOCK)
    where condition
    group by columns
)
where condition

more crud on table1
.
.
.

If I insert some logging statements into the stored proc I can see that when it hangs it hangs on the insert/select. Wondering if this could be a weird consequence of the NOLOCK statement. We (and by we I mean my boss :)) added the nolock because giant_table_1 and giant_table_2 are constantly being changed. Without the nolock our sproc was getting blocked a lot by other long running processes and vice versa.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:16:38+00:00Added an answer on May 27, 2026 at 8:16 pm

    Union can be a real hog. To test it you could do the individual inserts and see if the Union is significantly longer than the sum of the individual inserts.

    If union is the hog I would try to refactor without the union but that last where condition may not allow you to break it down. Pretend you can move the last where into the into the individual wheres.

    insert into table1 with (holdlock) 
    select columns
    from giant_table_1 WITH (NOLOCK)
    where conditionPlus
    group by columns
    order by giant_table_1.PKoftable1;
    
    insert into table1 with (holdlock) 
    select columns
    from giant_table_2 WITH (NOLOCK)
    where conditionPlus 
    and conditionToEliminateInsertsAlreadyInTable1
    group by columns
    order by giant_table_2.PKoftable1;
    

    Notice the order by PK of table1. This can be huge. It is way faster to sort the insert than perform page splits. Tune the fill factor on Table1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a pretty strange problem. I have a book that I have been
This is a pretty strange issue, but I think it might be that I
This is pretty weird. I have my Profiler open and it obviously shows that
This is a strange one that I cannot see to figure out. I have
I am having some pretty strange symptoms with JPanels and CardLayout. Essentially, I have
I'm having a strange issue with my AdvancedDataGrid. I have a pretty basic (no
I have an app I'm working on at the moment with some pretty strange
I've got a strange problem here. Assume that I have a class with some
I am having a strange issue that I have never encountered in the past
this is pretty strange. I've got this string that connect to a SQLServer in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.