SQL Maintenance for On-Prem Retail Databases: Indexes, Backups, and Honest Schedules
5% and 30%. Those two numbers do more honest work in a SQL maintenance plan than most nightly jobs do. Below 5% fragmentation, an index is left alone. Between 5% and 30%, it is reorganized. Above 30%, it is rebuilt. A plan that rebuilds every index every night ignores all three thresholds, it spends the maintenance window proving effort, not following evidence.
Retail sharpens the problem. The database is busiest when offices are empty, so the quiet hours a generic schedule assumes may be peak trading. A defensible plan for an on-premises retail database therefore starts with thresholds and sequencing, and only then with times on a clock.
Indexes: thresholds, not rituals
The sourced rule is simple to state: rebuild an index when fragmentation is more than 30%, and reorganize it when fragmentation sits between 5% and 30%. Below that band, index work is window time spent for no measured gain.
Sequencing matters as much as the thresholds. Index maintenance belongs in a dedicated window with no other operations running, no backups, no statistics updates, and no business operations alongside it. On a retail server, that window has to be chosen against trading hours, not copied from an office schedule: the right question is when this database is genuinely quiet, which each chain has to answer from its own trading pattern.
One more sizing point from the same source: long-running tables should be identified, so their rebuilds can be scheduled off-hours individually rather than holding the whole window hostage.
- Measure fragmentation first. List indexes with their fragmentation percentages before scheduling any work.
- Sort into the three bands. Under 5%: no action. 5% to 30%: reorganize. Over 30%: rebuild.
- Pull out the long runners. Flag tables whose rebuilds run long, and give each its own off-hours slot.
- Run index work alone. Keep the dedicated window free of backups, statistics updates, and business operations while index work runs.
- Log what ran. Record the job, the tables touched, and the outcome, so the next window starts from evidence.
What success looks like: the window closes with every index above 30% rebuilt, the 5% to 30% band reorganized, nothing under 5% touched, and a log entry that shows which tables were treated and why.
The shrink warning, stated plainly
Shrinking deserves its own section because plans keep scheduling it. Shrinking recovers space by moving data within the file, and it causes significant fragmentation; seasoned database administrators warn against it, and if shrinking is unavoidable, indexes should be rebuilt afterwards.
Read that sequence again. A scheduled shrink creates the fragmentation that the index job then has to repair. Put shrink in the plan as a regular task and the plan is, in part, maintaining damage of its own making. The honest treatment is narrower: shrink is an occasional, deliberate act with an index rebuild after it, never a standing line in the cadence below.
Backups: a schedule is not a restore
Maintenance plans can schedule full and differential database backups and transaction-log backups, with retention settings. Backups should also run regularly, especially after large data changes. Those are sourced statements about scheduling, and scheduling is only half of the backup question.
The other half is proof, and here the sources are thin, so this is a recommendation rather than a sourced fact: test restores on a schedule, onto a separate location, and record whether the restored database opened and matched its expected state. A backup job that has never been restored is a hope with a timestamp. The restore test is what converts it into evidence.
Compression is an option inside that schedule, with a cost attached. Compressed backups are recommended in the advanced maintenance guidance, and they are CPU-intensive. On a retail server, CPU spent compressing a backup is CPU taken from something else, so compression, like everything else here, belongs in the quiet window, sized against the machine that has to run it.
| Backup decision | Sourced starting point | Honest check |
|---|---|---|
| Types in the plan | Full, differential, and transaction-log backups can all be scheduled, with retention | Does the plan actually use the types it claims, at the retention it claims? |
| Extra backups | Run backups regularly, especially after large data changes | Is there a trigger for an extra backup after a large change, or only the calendar? |
| Compression | Recommended, and CPU-intensive | Was the CPU cost measured in the window, or discovered during trading? |
| Restore proof | Recommendation in this framework, not a sourced requirement | When was the last restore test, and where is its result recorded? |
Statistics and integrity: the quiet tasks
Two tasks do unglamorous work. Update statistics gives the query optimizer current information to work from, and it is a standard maintenance-plan task alongside reorganize and rebuild work. Database integrity checks are the other standard component: a maintenance plan should run integrity checks, update statistics, perform backups, and rebuild indexes at prescheduled times.
The advanced guidance pairs an IndexOptimize procedure with a statistics-update script, scheduled nightly, and records activity in a CommandLog table. The practical split follows from the dedicated-window rule: statistics and integrity work get their own scheduled place, outside the dedicated index window, rather than being stacked into it while index work runs.
Housekeeping has a maintenance task of its own. Backup and restore history in the MSDB database can itself slow SQL Server Agent, and the stored procedure sp_delete_backuphistory removes old records. A plan that never cleans its own history eventually slows the machinery that runs the plan.
A cadence a store can actually keep
| Rhythm | Work | Reason it sits there |
|---|---|---|
| Nightly, in the quiet window | Threshold-based index work through an IndexOptimize-style job, with CommandLog recording; statistics script as scheduled | Fragmentation is handled when measured as needing it, and the log proves what ran |
| Weekly | Integrity check; review backup outcomes and the job history; clear old backup history if it is accumulating | Integrity and history are prescheduled plan components, not annual surprises |
| Monthly | Restore test; review which tables run long and re-slot their rebuilds off-hours | Restore proof and long-runner scheduling both decay if they are never revisited |
| Never on a schedule | Database shrink | Scheduled shrink manufactures fragmentation for the index job to repair |
That cadence is a starting framework built from the sourced thresholds, not a prescription for every server. Validate it against the fragmentation measurements and window lengths on the actual database, and adjust the rhythm, not the thresholds, when the evidence says the window is too small or too large.
Verifying the plan actually ran
Close the loop where the work is recorded. Check the CommandLog for the index and statistics jobs, check backup and restore history, while remembering that same history needs periodic clearing so it does not slow the Agent, and confirm the dedicated index window really was dedicated, with no backup or statistics job overlapping it.
A plan that ran, at the thresholds it claims, in a window that stayed clear, with a restore test on record: that is the whole standard. Anything less is a schedule describing intentions, and intentions are not maintenance.
, Dex Carter, Tech Writer
NextData Retention Policies: Automated Cleanup That Respects the Audit Trail →