---
title: DatabaseMaintenance System Parameter – Nightly Log Database Maintenance
description: "DatabaseMaintenance turns the Nodinite Logging Service's nightly Log Database maintenance on or off with a JSON value: reorganize indexes above 15% fragmentation and shrink archive Log Databases. Default {\"Enabled\":true}."
---

# DatabaseMaintenance - System Parameter

**DatabaseMaintenance** turns the nightly [Log Database][Log Databases] 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)][1]  
*Animated walkthrough: the value is JSON, not a plain boolean. `{"Enabled":false}` makes the Logging Service skip the next maintenance window; the [Log Audit][Log Audits] shows each night's run.*

## :fa-table: At a Glance {#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 |

## :fa-gears: 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][AlwaysOn] are skipped.
* The [Log Audit][Log Audits] 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][Message Types] runs separately; see [Data Retention][Logging Service - 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.

## :fa-lightbulb: 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:

```sql
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][].

## :fa-hand-point-right: Next Steps

* :fa-database: [Log Databases][]  
* :fa-list: [Manage Log Databases][]  
* :fa-shield-halved: [SQL Server Sysadmin Requirements][]  
* :fa-pen-to-square: [Manage System Parameters][]  

## :fa-link-horizontal: Related Topics

* :fa-sort-size-up-alt: [SizeToSplitDatabaseOn][]  
* :fa-calendar-day: [DaysToSplitDatabaseOn][]  
* :fa-database: [LogDatabaseName][]  
* :fa-disc-drive: [LogLocations][]  
* :fa-life-ring: [LogDatabaseRecovery][]  
* :fa-user-secret: [LogAccessRoles][]  
* :fa-users-class: [LogServiceUsers][]  
* :fa-server: [AvailabilityGroupBackupPath][]  
* :fa-clock: [CleanUpTimerInterval][]  
* :fa-hard-drive: [Logging Service][]  
* :fa-sliders: [System Parameters][]  

[1]:{ndm}/Documentation%20Pictures/IM/CoreServices/ConfigurationDatabase/SystemParameters/SystemParameters_DatabaseMaintenance.gif

[AlwaysOn]:{ndr}/Install%20and%20Update/Troubleshooting/SQL%20Server/Always%20On%20Availability%20Groups.md
[AvailabilityGroupBackupPath]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/AvailabilityGroupBackupPath.md
[CleanUpTimerInterval]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/CleanUpTimerInterval.md
[DaysToSplitDatabaseOn]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/DaysToSplitDatabaseOn.md
[Log Audits]:{ndr}/Administration/6.%20Tools/2.%20Log%20Audit%20Search.md
[Log Databases]:{ndr}/Core%20Services/Log%20Databases/Overview.md
[LogAccessRoles]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/LogAccessRoles.md
[LogDatabaseName]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/LogDatabaseName.md
[LogDatabaseRecovery]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/LogDatabaseRecovery.md
[Logging Service]:{ndr}/Core%20Services/Logging%20Service/Overview.md
[Logging Service - Data Retention]:{ndr}/Core%20Services/Logging%20Service/Overview.md#data-retention
[LogLocations]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/LogLocations.md
[LogServiceUsers]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/LogServiceUsers.md
[Manage Log Databases]:{ndr}/Administration/5.%20Settings/2.%20Log%20Databases/Overview.md
[Manage System Parameters]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/Manage%20System%20Parameters.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[SizeToSplitDatabaseOn]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/SizeToSplitDatabaseOn.md
[SQL Server Sysadmin Requirements]:{ndr}/Install%20and%20Update/Troubleshooting/SQL%20Server/SQL%20Server%20Sysadmin%20Requirements.md
[System Parameters]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/Overview.md