Optimize pg_checksums --enable where checksum is already set
authorMichael Paquier <michael@paquier.xyz>
Wed, 30 Jun 2021 00:58:59 +0000 (09:58 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 30 Jun 2021 00:58:59 +0000 (09:58 +0900)
commit4c9f50d116461617848601e97dbc6f122b0a6f14
tree3d4e39d211e66bfe451014bdee74698dfb3f0f38
parent178ec460db0a0ced46ac5a01a28a704ca6251e53
Optimize pg_checksums --enable where checksum is already set

This commit prevents pg_checksums to do a rewrite of a block if it has
no need to, in the case where the computed checksum matches with what's
already stored in the block read.  This is helpful to accelerate
successive runs of the tool when the previous ones got interrupted, for
example.

The number of blocks and files written is tracked and reported by the
tool once finished.  Note that the final flush of the data folder
happens even if no blocks are written, as it could be possible that a
previous interrupted run got stopped while doing a flush.

Author: Greg Sabino Mullane
Reviewed-by: Paquier Michael, Julien Rouhaud
Discussion: https://postgr.es/m/CAKAnmmL+k6goxmVzQJB+0bAR0PN1sgo6GDUXJhyhUmVMze1QAw@mail.gmail.com
doc/src/sgml/ref/pg_checksums.sgml
src/bin/pg_checksums/pg_checksums.c