Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase ««12

Slow running query Expand / Collapse
Posted Thursday, February 27, 2014 10:00 AM



Group: General Forum Members
Last Login: Today @ 12:11 PM
Points: 5,654, Visits: 8,178
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.


Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru at GMail
Post #1545986
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse