Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Blocking Issue:Insert blocking select statements Expand / Collapse
Author
Message
Posted Friday, September 24, 2010 9:55 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, March 7, 2014 1:20 AM
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.
Post #992924
Posted Friday, September 24, 2010 10:21 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 1:06 PM
Points: 2,829, Visits: 8,479
Can you schedule the 2 jobs so they don't conflict ? If they are both EOD jobs, maybe they should run consecutively ?


Post #992947
Posted Friday, September 24, 2010 2:12 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, September 11, 2014 2:28 PM
Points: 1,194, Visits: 2,219
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
Post #993086
Posted Monday, September 27, 2010 12:59 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 12:26 AM
Points: 2,840, Visits: 3,963
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
Post #993466
Posted Monday, September 27, 2010 2:19 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 10:49 PM
Points: 883, Visits: 4,105
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
Post #993494
Posted Tuesday, September 28, 2010 11:38 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 30, 2010 12:30 AM
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.
Post #994928
Posted Saturday, May 26, 2012 6:57 AM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Saturday, September 13, 2014 12:30 AM
Points: 27, Visits: 470
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
Post #1306956
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse