Re: Why does pg_class.reltuples count only live tuples in indexes (after VACUUM runs)?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Why does pg_class.reltuples count only live tuples in indexes (after VACUUM runs)?
Date: 2022-04-18 20:10:44
Message-ID: 2376063.1650312644@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Geoghegan <pg(at)bowt(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2022-04-18 20:12:33 Re: Why does pg_class.reltuples count only live tuples in indexes (after VACUUM runs)?
Previous Message Bruce Momjian 2022-04-18 20:10:23 Re: GSOC proposal for Improve pgarchives by Yedil