PG_CHECKSUMS(1)
πΎ pg_checksums(1) β the data checksums glow-up π
okay bestie, sit down, because we're talking about pg_checksums β the PostgreSQL 17.11 utility that enables, disables, or checks data checksums in a PostgreSQL database cluster. she's giving maintenance-mode main character energy and honestly? iconic. π
β¨ SYNOPSIS β¨
pg_checksums [option...] [[-D | --pgdata]datadir]
that's it. that's the whole vibe. options, then optionally the data directory. slay. π¦
πΈ DESCRIPTION πΈ
so what does pg_checksums actually do? she checks, enables, or disables data checksums in a PostgreSQL cluster. periodt. π
but β and this is the important part, no cap β the server must be shut down cleanly before running pg_checksums. like, cleanly. don't just yank the plug and come running to her, okay? π
the exit status tea β:
- when verifying checksums: exit status is zero if there are no checksum errors, and nonzero if at least one checksum failure is detected.
- when enabling or disabling checksums: exit status is nonzero if the operation failed.
and the behind-the-scenes lore, because it's lowkey fascinating:
- verifying checksums scans every file in the cluster. all of them. she's thorough. π
- enabling checksums rewrites each relation file block with a changed checksum in-place.
- disabling checksums only updates the file
pg_control. that's the whole thing. tiny little update, huge vibe shift. β¨
π OPTIONS π
the following command-line options are available, bestie β collect them all:
-Ddirectory,--pgdata=directory β tells her where the database cluster lives. that's the directory, okay? don't make her guess. π-c,--checkβ checks checksums. this is the default mode if nothing else is specified, so if you just run her with no flags she's already doing this. default queen behavior. π-d,--disableβ disables checksums. bye bye checksums. π-e,--enableβ enables checksums. hello checksums, welcome to the group chat. π«Ά-ffilenode,--filenode=filenode β only validate checksums in the relation with filenode filenode. very "I'm only checking this one" of you. π-N,--no-syncβ by default,pg_checksumswaits for all files to be written safely to disk. this option makes her return without waiting, which is faster, but β and this is the scary part β it means a subsequent operating system crash can leave the updated data directory corrupt. generally this option is useful for testing but should not be used on a production installation. also, this option has no effect when using--check. so basically: fast and risky, only for the test girlys. π-P,--progressβ enable progress reporting. turning this on will deliver a progress report while checking or enabling checksums. she'll keep you posted, bestie. π--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,syncfsmay 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. seerecovery_init_sync_methodfor info about the caveats to be aware of when usingsyncfs. this option has no effect when--no-syncis used. π§-v,--verboseβ enable verbose output. lists all checked files. every single one. she's a yapper and we love her for it. π¬-V,--versionβ print thepg_checksumsversion and exit. quick lil flex. β-?,--helpβ show help aboutpg_checksumscommand line arguments, and exit. when in doubt, ask for help, that's literally what it's for. π
π¦ ENVIRONMENT π¦
PGDATAβ specifies the directory where the database cluster is stored; can be overridden using the-Doption. so-Dalways wins the argument, sorryPGDATA. πPG_COLORβ specifies whether to use color in diagnostic messages. possible values arealways,autoandnever. yes she has a color setting, because aesthetics matter. π¨
π NOTES π
okay, listen up, because these are the real ones:
- 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. not being dramatic β that's literally what it says. ππ
- 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. when enabling or disabling checksums in a replication setup, it is thus 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. so like β consistent across every node, or nuke-and-rebuild. no in-between. π - if
pg_checksumsis aborted or killed while enabling or disabling checksums, the cluster's data checksum configuration remains unchanged, andpg_checksumscan be re-run to perform the same operation. she's got your back, fr fr β no half-finished mess. π«Άβ¨
ngl bestie, the takeaway is: shut the server down cleanly, don't touch the data directory while she's working, and be consistent across your replicas. do that and she'll slay every single time. π
and that's the whole page, mwah π β this was PG_CHECKSUMS(1), straight outta the PostgreSQL 17.11 Documentation, dated 2026. go forth and checksum responsibly, ily π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms