Re: Why does pg_class.reltuples count only live tuples in indexes (after VACUUM runs)? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Why does pg_class.reltuples count only live tuples in indexes (after VACUUM runs)?
Date
Msg-id 2376063.1650312644@sss.pgh.pa.us
Whole thread Raw
In response to Re: Why does pg_class.reltuples count only live tuples in indexes (after VACUUM runs)?  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: Why does pg_class.reltuples count only live tuples in indexes (after VACUUM runs)?  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-hackers
Peter Geoghegan <pg@bowt.ie> writes:
> I think that this doesn't really belong here; new_rel_tuples should
> only be used for VACUUM VERBOSE/server log output, once we return to
> heap_vacuum_rel from lazy_scan_heap. We should use
> vacrel->new_live_tuples as our IndexVacuumInfo.num_heap_tuples value
> in the amvacuumcleanup path (instead of new_rel_tuples). That way the
> rule about IndexVacuumInfo.num_heap_tuples is simple: it's always
> taken from pg_class.reltuples (for the heap rel). Either the existing
> value, or the new value.

The places where index AMs refer to num_heap_tuples seem to be using
it as a ceiling on estimated index tuple counts.  Given that we should
be counting dead index entries, redefining it as you suggest would be
wrong.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: TRAP: FailedAssertion("HaveRegisteredOrActiveSnapshot()", File: "toast_internals.c", Line: 670, PID: 19403)
Next
From: Peter Geoghegan
Date:
Subject: Re: Why does pg_class.reltuples count only live tuples in indexes (after VACUUM runs)?