September 24, 2010 at 9:55 am
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.
September 24, 2010 at 10:21 am
Can you schedule the 2 jobs so they don't conflict ? If they are both EOD jobs, maybe they should run consecutively ?
September 24, 2010 at 2:12 pm
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
September 27, 2010 at 12:59 am
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;-)
September 27, 2010 at 2:19 am
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
September 28, 2010 at 11:38 pm
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.
May 26, 2012 at 6:57 am
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
😛
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply