SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Slow running query


Slow running query

Author
Message
TheSQLGuru
TheSQLGuru
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12565 Visits: 8559
peter.cox (2/27/2014)
In case anyone's still interested (!) I've pretty much worked out what the issue was; after fully dissecting the code (as I say - there's a lot; 65 steps, with some of the SPs running into 2k lines) I worked out one of the main tables was deleting 38m rows (out of of 41m), then reinserting them again, having been recalculated.

Obviously the SP that referenced the [now completely new] table had been optimized for different data. Adding the Recompile - either as "with recompile", or "option (recompile)" - for the complicated ones - does seem to have made all difference. It also explains why the scripts ran so fast when taking the SPs apart.

So far all seems okay. We're four days into the new regime and the job that had been taking up to 9.5 hours is now back under 7. Amazing difference.

Course, still savings to be made on other areas.

Thanks all though



For the 38/41M row delete, I would drop all indexes, do the delete, add data, recreate indexes if possible. That could substantially improve overall performance and tlog size too.

Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
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