Shrink transaction logs


Job details

Name: Shrink transaction logs
Platform: Sqlserver
Category: Maintenance
Premium package: Maintenance package
Description: This procedure shrinks transaction log files which are detected by ‘Transaction log size check’ alert which checks the size of the transaction log (log file(s) size), and compares it to the database size (data file(s) size).
Long description: This procedure shrinks transaction log files which are detected by ‘Transaction log size check’ alert which checks the size of the transaction log (log file(s) size), and compares it to the database size (data file(s) size). Only transaction logs with one file can be shrinked.
Version: 1.2
Default schedule: 10 5 6 *
Requires engine install: Yes
Compatibility tag: .[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2005′ & hasengine=‘YES’]/.[eng_inst_priv = 0 & (engine_edition = ‘Microsoft SQL Server’ engine_edition = ‘Azure SQL Managed Instance’)]

Parameters

Name Default value Description
min transaction log size 2000 The minimum size (in MB) of the transaction log files that will be shrinked.
max transaction log size 10000 The maximum size (in MB) of the transaction log files that will be shrinked.
ratio threshold (%) 300 The ratio threshold (in percent) between the data file size and the transaction log file size. If the size of the transaction log file is twice as large in comparison with the total size of the data file(s), then the ratio is 200%. Only transaction log files above this threshold will be shrinked.
ignore databases The list of databases to ignore (separated by comma).
enable shrinking NO Set to YES to enable shrinking.
ratio threshold after (%) 80 The ratio threshold (in percent) between the data file size and the transaction log file size after shrinking.
history threshold 10 Shrink history records per database.

Job Summary

SELECT dbname "Database", round(cast(data_size as bigint), 1) "Data size", num_data_files "Data file count", round(cast(log_size as bigint), 1) "Log size", num_log_files "Log file count", round(ratio, 1) "Ratio", log_space_used_pct "Log space used", histr_date "Warning date"
FROM dbw_shrink_trans_logs_table
ORDER BY ratio DESC;

Operations and Execution

Targets and Thresholds

Parameters Handled

(This section is not described in detail as per request, but includes thresholds for minimum and max transaction log sizes, ratios, databases to ignore, and enabling or disabling shrinking as major parameters affecting job execution.)

Dependencies

Automation and Reporting

Version and Maintenance

Extending and Customization