Re: Relstats after VACUUM FULL and CLUSTER

2025-05-22 Thread Sami Imseih
> In both cases, he recently dead tuples must be copied to the table or index, > but > they should not be counted towards reltuples. So, I think we need to fix this > in > heapam_relation_copy_for_cluster by probably subtracting > tups_recently_dead from num_tuples ( which is the value set in > p

Re: Relstats after VACUUM FULL and CLUSTER

2025-05-22 Thread Sami Imseih
> You need a concurrent transaction to recreate the situation. I am attaching > an isolation test to show the behavior, Thanks! That helps. Indeed heapam_relation_copy_for_cluster and heapam_index_build_range_scan are counting HEAPTUPLE_RECENTLY_DEAD ( tuples removed but cannot be removed ) diffe

Re: Relstats after VACUUM FULL and CLUSTER

2025-05-22 Thread Erik Nordström
Hi Sami, You need a concurrent transaction to recreate the situation. I am attaching an isolation test to show the behavior, along with its output file. I ran it on PostgreSQL 17.4. The test has two permutations, the first one runs on a table without an index and the second permutation with an in

Re: Relstats after VACUUM FULL and CLUSTER

2025-05-22 Thread Sami Imseih
> Does this seem like a bug or is it intentional? pg_class.reltuples/relpages are only an estimate as per documentation. However, I cannot reproduce the situation you are talking about on HEAD. In the below example, I create a table without indexes, then insert and delete some rows. run vacuum to

Relstats after VACUUM FULL and CLUSTER

2025-05-22 Thread Erik Nordström
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 c