- 3 minutes to read

DatabaseMaintenance - System Parameter

DatabaseMaintenance turns the nightly Log Database maintenance of the Logging Service on or off: reorganizing fragmented indexes and shrinking archive Log Databases. Turn it off only when your own SQL Server maintenance takes care of the Nodinite Log Databases.

DatabaseMaintenance opened from the System Parameters list: the JSON value {"Enabled":true} with Json model is valid and Data type json, changed to {"Enabled":false} and saved, then back to {"Enabled":true} and saved; Log Audit Search for the operation shrink shows last night's runs, Start shrink of 2 Log database(s) and Completed shrink of Log databases, by the Database Cleanup Worker of the Nodinite Logging Service, animated walkthrough (7.12)
Animated walkthrough: the value is JSON, not a plain boolean. {"Enabled":false} makes the Logging Service skip the next maintenance window; the Log Audit shows each night's run.

At a Glance

Property Value
Key DatabaseMaintenance
Data type json
Default {"Enabled":true}
Read by Logging Service
Takes effect The Logging Service reads the value every 10 minutes; a change applies in the next maintenance window. No restart needed.
Status ✅ Active
Since Nodinite 3

How It Works

When Enabled is true, the Logging Service runs maintenance once a day between 03:00 and 04:00, in the local time of the server it runs on. Its loop wakes every 10 minutes, so the start falls somewhere in that hour. The "once" is kept in memory: a Logging Service restart inside the window runs the maintenance again.

An empty value also means enabled. A value that isn't valid JSON turns maintenance off for that run, and the Logging Service logs it as critical.

Log Database Maintenance
Online Log Database Reorganize indexes above 15% fragmentation.
Archive Log Databases Reorganize indexes above 15% fragmentation. Shrink to return unused disk space to the operating system.
  • Read-only archive Log Databases and Log Databases in an Always On Availability Group are skipped.
  • The Log Audit records each run under the Function Database Cleanup Worker: Start shrink of N Log database(s), Reorganized of database: '…' changed N indexes to increase performance, Shrink of … saved N MB, and Completed shrink of Log databases. The Start shrink list also names the online Log Database, although only archives are shrunk.
  • Shrink is a privileged operation: the Logging Service account needs the sysadmin role. Take regular backups before you rely on it.
  • This parameter does not control retention. The removal of old data per Message Type runs separately; see Data Retention on the Logging Service page and CleanUpTimerInterval.

When Enabled is false, the Logging Service skips this maintenance, and your DBA must maintain the indexes and shrink the Log Databases.

Choosing a Value

  • Keep {"Enabled":true} (recommended), and exclude the Nodinite databases from your own maintenance jobs. Two maintenance processes on the same databases overlap and compete.
  • Set {"Enabled":false} only when your own jobs are meant to maintain the Nodinite Log Databases.
  • Set {"Enabled":false} when the Logging Service account is not sysadmin; otherwise the shrink fails every night. See SQL Server Sysadmin Requirements.

Example: Exclude Nodinite Databases in IndexOptimize

If you use Ola Hallengren's IndexOptimize and every Nodinite database name starts with Nodinite (the default LogDatabaseName pattern), exclude them with a wildcard:

EXECUTE dbo.IndexOptimize
    @Databases = 'USER_DATABASES,-Nodinite%',
    @FragmentationLow = NULL,
    @FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
    @FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
    @UpdateStatistics = 'ALL';

This excludes, for example, Nodinite_DEMO_Config and Nodinite_DEV_Log_20241108. Adjust the pattern if you changed LogDatabaseName.

Next Steps