SQL Server Maintenance Plans

sql server

I use the maintenance plan of SQL Server, but it does not work well.

Transaction log truncation flow in the maintenance plan:

① Database consistency check task
↓
② Database compression task
↓
③ Database backup task
(Transaction log backup)
↓
④ Truncate transaction log area (execute T-SQL)

If run the maintenance plan manually in the manual server, it will successfully terminate the transaction log area and reduce the size.

The size is not reduced while the transaction log area is truncated, even though the schedule is successfully terminated.

Is there any problem with the execution of the maintenance plan?

USE [XXX system _SQL] 
GO

DBCC SHRINKFILE (XXX system _SQL_log, TRUNCATEONLY) 
GO

Best Answer

If you need to shrink your log file often, it means that the size it has after a shrink is not sufficient for your everyday activity, so it grows again and again.

This means that you do unnecessary work when shrink it, and, that is worse, every time your log needs to expand, it wastes time zeroing out every new piece of file it adds (and your users WAIT for the completion of this zeroing out).

You should stop this double waste of time and eliminate log shrinking from your maintenance plan. If you are not satisfied with the size of your log, shrink it once and then make your log backups more frequently.