olahallengren / sql-server-maintenance-solution

SQL Server Maintenance Solution
https://ola.hallengren.com
MIT License
2.82k stars 728 forks source link

DBCC CHECKDB split for VLDB #377

Open ChrisWoods1977 opened 4 years ago

ChrisWoods1977 commented 4 years ago

It would be great if the consistency checks could split up a DB to follow Paul Randall's suggested split for VLDBs found at: https://www.sqlskills.com/blogs/paul/checkdb-from-every-angle-consistency-checking-options-for-a-vldb/

Figure out your largest tables (by number of pages) and split the total number into 7 buckets, such that there are a roughly equal number of database pages in each bucket. Take all the remaining tables in the database and divide them equally between the 7 buckets (using number of pages again) On Sunday: Run a DBCC CHECKALLOC Run a DBCC CHECKCATALOG Run a DBCC CHECKTABLE on each table in the first bucket On Monday, Tuesday, Wednesday: Run a DBCC CHECKTABLE on each table in the 2nd, 3rd, 4th buckets, respectively On Thursday: Run a DBCC CHECKALLOC Run a DBCC CHECKTABLE on each table in the 5th bucket On Friday and Saturday: Run a DBCC CHECKTABLE on each table in the 6th and 7th buckets, respectively

markaugust commented 4 years ago

I've been working on something similar to this. It doesn't follow this bucket approach, but rather does the checks in a rolling fashion, as we only have the ability to run checks during the weekends.

See MR #323. Feel free to contribute to/use my fork.

EitanBlumin commented 3 years ago

This is a much-needed feature. There's actually something like this already implemented by Microsoft's Tiger team in the Tiger Toolbox maintenance solution here:

https://github.com/microsoft/tigertoolbox/blob/master/MaintenanceSolution/5_job_Maintenance_MEA.sql#L628-L665

and here:

https://github.com/microsoft/tigertoolbox/blob/master/MaintenanceSolution/5_job_Maintenance.sql#L630-L667

It basically splits the tables into "daily" buckets based on size, while maintaining an isdone column for each bucket.

I suppose something like this could be implemented in Ola's solution as well, but also an alternative variation of it for those able to run the maintenance on weekends only: