Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Blocking Issue:Insert blocking select statements


Blocking Issue:Insert blocking select statements

Author
Message
ondrocks
ondrocks
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 128
I have a table 'accounts'.One of my select query in side a stored procedure 'EOD_Report' is is blocking the insert query defined in another stored procedure named 'login'.
Whenever 'EOD_Summary' stored procedure runs ,all our application freezes and users are not able to login.Since the EOD_Report takes min 45 min to execute we are facing business loss.

Is there is a way to avoid this or change the Isolation level which may help to run the insert statement simultaneously along with select.
homebrew01
homebrew01
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2980 Visits: 9071
Can you schedule the 2 jobs so they don't conflict ? If they are both EOD jobs, maybe they should run consecutively ?



sqlbuddy123
sqlbuddy123
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1212 Visits: 2243
1. Try to create an appropriate index so that the Report Stored Proc doesn't nun for 45 mins and thereby reducing the blocing time
2. OR Try to use read comitted snapshot isolation level which uses row versioning. Please note that this puts an additional load on the TempDB. So test before you use this.

Thank You

Best Regards,
SQLBuddy
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2924 Visits: 4076
If you can afford dirty reads then use with nolock

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
crazy4sql
crazy4sql
SSC Eights!
SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)

Group: General Forum Members
Points: 929 Visits: 4422
can you see the execution plan for this slowness, i.e., where the resources are consuming most.
Also just a suggestion to try, if you have select query in your SP, just run the query with hint.
Like select...............from tablename where conditions(if applicable)
with recompile.

Also try to recompile your SP. Might be stats are not updated in those table.
Check the index fregmentation level of the tables used in SP.

----------
Ashish
bharathy.ramalingam
bharathy.ramalingam
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 5
Review the execution plan of that SP and the access mode of that particular table. Could be a table level lock due to full-table scan. Add appropriate index to eliminate the table scan. Don't think resource is a problem, until unless the CPU utilizaiton is constantly high for whole blocking period.
jswong05
jswong05
Valued Member
Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)

Group: General Forum Members
Points: 59 Visits: 476
The reason large select is blocking is due to lock-escalation. In SQLServer2008, you can disable lock-escalation by command set lock-escalation disable. How big is your select? How many tables? Have you measured IO and time? You should try to tune that SP to see if you can minimize the resource usage, optimize the query.

For performance tuning, please see my SQLsaturday#57 presentation. (too much to mention)

I solved this kind of problem before (in a poor-man's 2005 environment) by producing the select into a physical table over night (like Oracle materialized view, extra GB space needed in my case). It won't be real-time though. If you have to, you can utilize database snapshot for the report queries. Obviously, warehouse queries should be handled separated from OLTP queries.

Snapshot isolation utilizes row-versioning instead of locking, but be prepared with tempdb resource depending on how large is your select query, and whether you are near or out of IO capacity.

Jason
http://dbace.us
:-P
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search