Thursday, May 24, 2012

How SQL recovery models change the behavior of the transaction log

The transaction log is the most important part of SQL Server database at the time of SQL Server database recovery. A transaction log is a sequential record of ongoing transaction and past transactions while the actual data is contained in a separate file. If the transaction log got damaged after any crash, then crashed recovery cannot possible & it's lead to a suspect database. In such situation, the database must be restored from backups or recovered by using emergency mode repair.

Transaction log behavior depends on the recovery model that a database is using. There are three types recovery models available in SQL Server:

1. Simple Logged
2. Full Logged
3. Bulk Logged.

All Recovery Models have different effects on transaction log behavior.

In Simple Recovery model, log backup are not supported. So If SQL Server database got corrupted in this recovery model, a restore to point in time cannot be possible. In this case, the database cannot restore until the last full backup or differential backup is available. Therefore, in this recovery model, the database must be backed up frequently to avoid the data loss as much as possible. Simple recovery model is advisable to use for user databases, development and testing scenarios.

Bulk-logged recovery model is advisable for user database where the bulk operations are performed. If log backup contains bulk log operations then the SQL Server database can be recovered from the end of the log backup and in this case the point in time recovery is not possible. If the log backup does not have bulk operations, then the point in time recovery is easily possible.

Full Recovery model is recommended for those users who cannot afford to lose their precious data such as for production databases, critical environments etc. This recovery model supports point in time recovery. In full recovery model, The Transaction log of the database and the transactions are retain until a log backup is performed.
Before using the recovery models, the people should be necessary to understand the role of transaction log in every SQL Server recovery models. This article shows important information to understand that.

No comments:

Post a Comment