Wednesday, May 6, 2015

Transaction Log Physical Architecture


SQL Server uses transaction log for data integrity and data recovery. The sequences of log records are in set of physical files that implement transaction log.

SQL Server divide physical log files in small sized virtual log files, the size and number of virtual log files are decided by SQL server internally;

DBA can never configure virtual log files but can configure the size and number of physical log files.
When a database is created a physical log file is added, let us consider the example physical log file with six logical log files.

When new records are comes in, it added to the end of the logical log and expand toward the end of the physical log file.
Log truncation frees all the virtual log file prior to minimum LSN (minLSN), minimum LSN is the oldest number which require for successful database wide rollback.




When end of logical log reaches start of logical log, two things happens.
1. When physical file growth is enabled a new log record is added to extension
2. When physical file growth is disabled or disk has less space than error 9002 generates.
When database have multiple physical log file than logical file move through all physical files before wrap to first physical log file.

select * FROM sys.fn_dblog (NULL, NULL) // this gives us log file info.


No comments :

Post a Comment