Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a large transaction log affect performance?

Tags:

sql-server

I have seen that our database has the full recovery model and has a 3GB transaction log.

As the log gets larger, how will this affect the performance of the database and the performance of the applications that accesses the database?

like image 379
JD. Avatar asked Aug 09 '09 15:08

JD.


People also ask

Does transaction log size affect performance?

Having multiple log files in a database does not enhance performance in any way, because the transaction log files do not use proportional fill like data files in a same filegroup. Log files can be set to shrink automatically.

What happens when transaction log is full?

When the transaction log becomes full, SQL Server Database Engine issues a 9002 error. The log can fill when the database is online, or in recovery. If the log fills while the database is online, the database remains online but can only be read, not updated.

How big should my transaction log be?

Although there is no one optimal value for Transaction Log File initial size and auto-growth that fits all situations, but setting the initial size of the SQL Server Transaction Log file to 20-30% of the database data file size and the auto-growth to a large amount, above 1024MB, based on your database growth plan can ...

What is the significance of transaction log?

A transaction log is used to record the fact that a transaction is set to occur as well as the information needed by the database server to recover the data back to a consistent state in event of a sever failure while it is writing information to disk.


1 Answers

The recommended best practice is to assign a SQL Server Transaction log file its’ very own disk or LUN.

This is to avoid fragmentation of the transaction log file on disk, as other posters have mentioned, and to also avoid/minimise disk contention.

The ideal scenario is to have your DBA allocate sufficient log space for your database environment ahead of time i.e. to allocate say x GB of data in one go. On a dedicated disk this will create a contiguous allocation, thereby avoiding fragmentation.

If you need to grow your transaction log, again you should endeavour to do so in sizeable chunks in order to endeavour to allocate contiguously.

You should also look to NOT shrink your transaction log file as, repeated shrinking and auto growth can lead to fragmentation of the data file on disk.

I find it best to think of the autogrowth database property as a failsafe i.e. your DBA should proactively monitor transaction log space (perhaps by setting up alerts) so that they can increase the transaction log file size accordingly to support your database usage requirements but the autogrowth property can be in place to ensure that your database can continue to operate normally should unexpected growth occur.

A larger transaction log file in itself if not detrimental to performance as SQL server writes to the log sequentially, so provided you are managing your overall log size and allocation of additional space appropriately you should not be concerned.

like image 145
John Sansom Avatar answered Oct 24 '22 21:10

John Sansom