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:

  • -D directory, --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.
  • -f filenode, --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_checksums will 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 to fsync, which is the default, pg_checksums will 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 the pg_checksums version and exit.
  • -?, --help β€” show help about pg_checksums command 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 -D option.
  • PG_COLOR β€” specifies whether to use color in diagnostic messages. possible values are always, auto and never.

πŸ’œ 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 πŸ’–βœ¨πŸŽ€