# pd_lsn vs record LSN

Two LSNs that are easy to mix up, and the rule recovery uses to compare them.

> Canonical URL: https://sudohulk.com/writing/pd-lsn-vs-record-lsn
> Type: note · Stream: Tech
> Maturity: budding. Checked once; the structure holds.
> Published: 2026-09-21
> Tags: postgresql
> Reading time: 1 min
> Author: Vignesh Kumar A <vignesh@sudohulk.com>
> Licence: CC BY 4.0. Quote freely, cite the canonical URL.

---

Every WAL record has an address in the log stream: its **record LSN**. Every 8 KB data page also carries an LSN in its header, `pd_lsn`: the **page LSN**, which is the address just past the most recent WAL record already applied to that page.

The rule that makes crash recovery idempotent: when replaying a record for a page, PostgreSQL applies it only if `pd_lsn` is older than the record's LSN. If the page already shows a newer LSN, that change reached disk before the crash and is skipped.

:::gotcha
An LSN is meaningful only inside one server. Two nodes' `1/2D3E` have nothing to do with each other. Never compare LSNs across machines.
:::

Related: [[full-page-writes-and-torn-pages]] (once written).
