IT lexicon › Database › Log sequence number

Log sequence number

Database På svenska → Updated: 2026-11-11

A strictly-increasing ID assigned to each record written to the database log, marking the point of recovery after a crash.

Every change to a database is written first to a transaction log (write-ahead logging). Each log entry gets a sequence number: LSN 1, 2, 3, etc. If the database crashes, the system knows: "We wrote up to LSN 5847, so anything from LSN 5848 onward must be rolled back." Pages in memory are also tagged with their latest LSN — a page can only be written to disk if all changes up to its LSN have been logged.

LSN is abstract but elegant: not a timestamp (which can drift), not a file offset (which can shift) — just a counter that says where in log history the system is. Every modern database uses something similar.

← Back to the lexicon