]> granicus.if.org Git - postgresql/commit
Avoid having vacuum set reltuples to 0 on non-empty relations in the
authorAndrew Gierth <rhodiumtoad@postgresql.org>
Thu, 16 Mar 2017 22:31:49 +0000 (22:31 +0000)
committerAndrew Gierth <rhodiumtoad@postgresql.org>
Thu, 16 Mar 2017 22:31:49 +0000 (22:31 +0000)
commit9b626f6c334f95f1052b22b13d9ddbcc4de5fc4f
treee965d9791f6ee1f5afc3c19626d82e05e75d9c51
parent41306a511c01dd299115cf447858a00e34aebbf6
Avoid having vacuum set reltuples to 0 on non-empty relations in the
presence of page pins, which leads to serious estimation errors in the
planner.  This particularly affects small heavily-accessed tables,
especially where locking (e.g. from FK constraints) forces frequent
vacuums for mxid cleanup.

Fix by keeping separate track of pages whose live tuples were actually
counted vs. pages that were only scanned for freezing purposes.  Thus,
reltuples can only be set to 0 if all pages of the relation were
actually counted.

Backpatch to all supported versions.

Per bug #14057 from Nicolas Baccelli, analyzed by me.

Discussion: https://postgr.es/m/20160331103739.8956.94469@wrigleys.postgresql.org
src/backend/commands/vacuumlazy.c
src/test/isolation/expected/vacuum-reltuples.out [new file with mode: 0644]
src/test/isolation/isolation_schedule
src/test/isolation/specs/vacuum-reltuples.spec [new file with mode: 0644]