PG_CHECKSUMS(1)
β¨ PG_CHECKSUMS(1) β¨
okay bestie, so this is the manual page for pg_checksums, page 1 of the PostgreSQL 18.6 documentation, and it's literally about checking, turning on, or turning off data checksums in a PostgreSQL cluster. let's get into it π
πΈ NAME πΈ
pg_checksums β enable, disable or check data checksums in a PostgreSQL database cluster
no cap, that's the whole job. checksums. in. a. cluster. π
π SYNOPSIS π
pg_checksums [option...] [[-D | --pgdata]datadir]
that's it, that's the shape of it. options, then optionally where your data lives π«Ά
π DESCRIPTION π
so pg_checksums checks, enables, or disables data checksums in a PostgreSQL cluster. that's the vibe.
the one thing you cannot skip: the server has to be shut down cleanly before you run pg_checksums. like, cleanly cleanly. not "eh it's fine" cleanly. π₯
here's the exit-status tea, because it differs depending on what you're doing:
- when you're verifying checksums, the exit status is zero if there are no checksum errors, and nonzero if at least one checksum failure is detected.
- when you're enabling or disabling checksums, the exit status is nonzero if the operation failed.
now the mechanics, because this part is kinda iconic:
- when verifying checksums, every single file in the cluster is scanned. all of them. the whole thing. π
- when enabling checksums, each relation file block with a changed checksum is rewritten in-place.
- disabling checksums only updates the file
pg_control. that's it. one file. lowkey efficient.
β OPTIONS β
these are the command-line options, and there are a bunch, so buckle up bestie:
-Ddirectory,--pgdata=directory β tells it where the database cluster is stored. your data's home address π-c,--checkβ checks checksums. and surprise, this is the default mode if you don't specify anything else. it's giving main character energy by default β¨-d,--disableβ disables checksums.-e,--enableβ enables checksums.-ffilenode,--filenode=filenode β only validate checksums in the relation with filenode filenode. so you're not checking the whole world, just that one relation π―-N,--no-syncβ okay so by default,pg_checksumswill wait for all files to be written safely to disk. this option makes it return without waiting, which is faster, but means that a subsequent operating system crash can leave the updated data directory corrupt. π generally this is useful for testing but should not be used on a production installation. also, this option has no effect when using--check.-P,--progressβ enable progress reporting. turn this on and you'll get a progress report while checking or enabling checksums. very satisfying, 10/10 π--sync-method=method β when set tofsync, which is the default,pg_checksumswill recursively open and synchronize all files in the data directory. the search for files will follow symbolic links for the WAL directory and each configured tablespace.
on Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. see recovery_init_sync_method for information about the caveats to be aware of when using syncfs.
this option has no effect when --no-sync is used.
-v,--verboseβ enable verbose output. lists all checked files. yes, all of them π-V,--versionβ print thepg_checksumsversion and exit.-?,--helpβ show help aboutpg_checksumscommand line arguments, and exit.
π ENVIRONMENT π
environment variables, the sneaky little settings π
PGDATAβ specifies the directory where the database cluster is stored; can be overridden using the-Doption.PG_COLORβ specifies whether to use color in diagnostic messages. possible values arealways,autoandnever.
π NOTES π
enabling checksums in a large cluster can potentially take a long time. during this operation, the cluster or other programs that write to the data directory must not be started or else data loss may occur. like, do not touch it. do not open it. do not look at it funny. π
when using a replication setup with tools which perform direct copies of relation file blocks (for example pg_rewind(1)), enabling or disabling checksums can lead to page corruptions in the shape of incorrect checksums if the operation is not done consistently across all nodes. so when you're enabling or disabling checksums in a replication setup, it's recommended to stop all the clusters before switching them all consistently. destroying all standbys, performing the operation on the primary and finally recreating the standbys from scratch is also safe. pick your path, just be consistent bestie π¦
and the good news: if pg_checksums is aborted or killed while enabling or disabling checksums, the cluster's data checksum configuration remains unchanged, and pg_checksums can be re-run to perform the same operation. no permanent damage, we love a reversible queen π
and that's the whole page, bestie!! this was PostgreSQL 18.6, dated 2026, and honestly? checksums never looked so good. go forth and verify responsibly πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms