Parameter · Preset Options
data_checksums
Shows whether data checksums are turned on for this cluster.
- Default:
off - Type: bool
- Applies: Read-only
In plain words
With checksums on, PostgreSQL stores a small fingerprint in every data page when writing it and verifies it when reading it back. If the disk or controller silently changed the page, you get an error instead of wrong data.
Since PostgreSQL 18, initdb enables checksums by default.
For DBAs and operators
Decided at initdb (--data-checksums, or --no-data-checksums in 18). It can be switched on or off later only with the cluster stopped, using pg_checksums --enable (rewrites every data file, time proportional to size) or --disable (only updates pg_control), or --check to verify offline.
What you see
The client gets ERROR: invalid page in block 4 of relation "base/16384/16385"; the server log also records LOG: page verification failed, calculated checksum 20919 but expected 15254 (in 18 at LOG level, written by the process that performed the read, often an I/O worker). Counters: pg_stat_database.checksum_failures and checksum_last_failure. ignore_checksum_failure = on lets you read past a bad page to salvage data (dangerous; superuser only): the read then only gives WARNING: ignoring checksum failure in block 4 of relation "base/16384/16385".
Cost and pitfalls
- CPU cost is small; the bigger cost is that hint-bit changes must be WAL-logged (as with
wal_log_hints), giving more full-page images after checkpoints. - pg_upgrade requires old and new clusters to match. With 18 defaulting to on, upgrading an older cluster created without checksums needs
initdb --no-data-checksumsfor the new one (or enable checksums on the old one first withpg_checksums). - Checksums cover data pages only (not WAL, which has its own CRCs, nor
pg_xact). They detect, they do not repair: you need backups or a replica.
How to change it
Fixed when PostgreSQL was built or the cluster was initialised. You can only read it.
See it in context
Page layout Full-page writes Commit log, hint bits and subtransactions
Related parameters
ignore_checksum_failure wal_log_hints full_page_writes block_size