Relstats after VACUUM FULL and CLUSTER

From: Erik Nordström <erik(at)timescale(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Relstats after VACUUM FULL and CLUSTER
Date: 2025-05-22 12:13:39
Message-ID: CACAa4VKmyz51BFAFZyKGBt9-yt8Vyk09s_26++FHy2ngfb9k0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I noticed a potential issue with the heap cluster code used by VACUUM FULL
and CLUSTER, but I am not sure so I thought I'd post the question to the
list.

The code in question counts the number of tuples it processes and uses that
count to update reltuples in pg_class. However, the tuple count seems off
sometimes because it includes recently dead tuples (due to updates and
deletes). However, the wrong reltuples count is set, AFAICT, only on tables
that don't have indexes because the cluster code also later rebuilds
indexes which then updates reltuples to the "correct" value.

Does this seem like a bug or is it intentional?

Best regards,

Erik

--
Database Architect, Timescale

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-05-22 12:15:11 Re: Avoid orphaned objects dependencies, take 3
Previous Message Pavel Stehule 2025-05-22 12:05:03 Re: Retiring some encodings?