Open ChrisWoods1977 opened 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.
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:
and here:
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:
isdone
column, maintain a last_check_datetime
column.last_check_datetime
value.@TimeLimit
parameter could be utilized to control your maintenance window size, and a bucket will be selected for a check as long as we're within the allowed time limit.last_check_datetime
would somehow need to be persisted between different executions.
last_check_datetime
as an extended property per each table.last_check_datetime
first, and the table's size second.
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