Re: [COMMITTERS] pgsql: Avoid having vacuum set reltuples to 0 onnon-empty relations in - Mailing list pgsql-committers

From Vik Fearing
Subject Re: [COMMITTERS] pgsql: Avoid having vacuum set reltuples to 0 onnon-empty relations in
Date
Msg-id CAJguA1SRBxPVJEs3knUnpvRcgzLTsmf2+mSXC-oRhXZJn+5pgw@mail.gmail.com
Whole thread Raw
In response to [COMMITTERS] pgsql: Avoid having vacuum set reltuples to 0 on non-empty relationsin  (Andrew Gierth <rhodiumtoad@postgresql.org>)
List pgsql-committers
On Thu, Mar 16, 2017 at 11:39 PM, Andrew Gierth <rhodiumtoad@postgresql.org> wrote:
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

Congrats on your first commit!

pgsql-committers by date:

Previous
From: Andrew Gierth
Date:
Subject: [COMMITTERS] pgsql: Avoid having vacuum set reltuples to 0 on non-empty relationsin
Next
From: Peter Eisentraut
Date:
Subject: [COMMITTERS] pgsql: psql: Add completion for \help DROP|ALTER