Log Manager Architecture

A Microsoft SQL Server 7.0 log file consists of one or more physical files that contain log entries only. Previously, the log file was a system table that used ordinary database pages. These log pages were allocated and deallocated in the same way as pages of other tables, and they competed with data pages for space in the memory cache.

Each log file is divided logically into smaller segments called virtual log files, which are the unit of truncation for the transaction log. When a virtual log file no longer contains log records for active transactions, it can be truncated and the space becomes available for logging new transactions.

SQL Server 7.0 avoids having lots of small virtual log files. The number of virtual log files grows more slowly than their size. If a log file grows in small increments, it usually will have many small virtual log files. If the log file grows in larger increments, SQL Server will create a smaller number of larger virtual log files.

As records are written to the log file, the end of the log file grows from one virtual log file to the next. If there is more than one physical log file for a database, the end of the log file grows through each virtual log file in each physical log file before circling back to the first virtual log file in the first physical log file.

The smallest size for a virtual log file is 256 KB. The minimum size for a transaction log is 512 KB, or two virtual log files of 256 KB each. Both the number and size of the virtual log files in a transaction log increase as the size of the log file increases. A small log file might have a very few small virtual log files. A very large log file will have larger virtual log files.

Log files can grow and shrink automatically. If there is no reusable space available, the log file will be extended by adding another logical log file chunk. If more space is needed, another logical log file is added. Internally, the log manager divides physical log files into logical log files. The logical log files are either active or reusable. A logical log file can be backed up if it does not contain any portion of the active log. A log file can be reused if it has been backed up.