liveBook · Manning

Log block

As explained in 100 SQL Server Mistakes and How to Avoid Them

A log block is a container for transaction log records and the unit in which those records are flushed to disk.

A log block is a container for transaction log records and the unit in which SQL Server flushes those records to disk. Log records capture DML and DDL activity; in Full recovery model, they also record allocated and deallocated pages and extents. section 9.5

Mistake: letting the log grow in small default increments. Growth creates virtual log files (VLFs), each containing log blocks; too many VLFs fragment the log and can hurt performance. Log truncation releases inactive VLFs, not the physical log file. section 9.5 section 9.12

Keep these operational rules in view:

  • Remember that an LSN identifies a log record through the VLF sequence number, log block ID, and log record ID. section 9.5
  • Expect the log to cycle back to the first truncated VLF after the final VLF becomes full. section 9.5
  • Investigate active VLFs retained by incomplete transactions, availability-group replicas, or change data capture before assuming truncation is failing. section 9.5

Check for log fragmentation

Run the supplied DMV query against MarketingArchive to compare actual VLF counts with minimum and maximum ideal counts derived from the log-file size. Use the result to identify growth-related fragmentation before changing the growth strategy.

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Traces log blocks through VLFs, LSNs, truncation, active-transaction retention, and cycling, then stops at diagnostic VLF counts.
Examples
Uses a transaction-log cycle figure and a DMV query comparing actual VLFs with ideal ranges.
What it assumes
Assumes basic database and transaction-log terminology while defining VLFs, log records, LSNs, and truncation relationships.
What you can do after
Diagnose/debug with it: interpret LSN structure, recognize VLF-related fragmentation, and inspect log fragmentation with SQL Server DMVs.
How it connects
Connects log blocks with transaction logs, VLFs, log records, LSNs, log truncation, availability groups, and change data capture.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.