Fix missing FSM vacuum opportunities on tables without indexes.
authorMasahiko Sawada <msawada@postgresql.org>
Wed, 2 Jul 2025 06:25:20 +0000 (23:25 -0700)
committerMasahiko Sawada <msawada@postgresql.org>
Wed, 2 Jul 2025 06:25:20 +0000 (23:25 -0700)
commit3811ca3600a31f999e4709de4a9c64c789992e14
tree57abd6c5ded98483870c8e9053b045c2905dccbd
parent9adb58a3ccb5ad28e773684db33ffcb1ebbd5ef1
Fix missing FSM vacuum opportunities on tables without indexes.

Commit c120550edb86 optimized the vacuuming of relations without
indexes (a.k.a. one-pass strategy) by directly marking dead item IDs
as LP_UNUSED. However, the periodic FSM vacuum was still checking if
dead item IDs had been marked as LP_DEAD when attempting to vacuum the
FSM every VACUUM_FSM_EVERY_PAGES blocks. This condition was never met
due to the optimization, resulting in missed FSM vacuum
opportunities.

This commit modifies the periodic FSM vacuum condition to use the
number of tuples deleted during HOT pruning. This count includes items
marked as either LP_UNUSED or LP_REDIRECT, both of which are expected
to result in new free space to report.

Back-patch to v17 where the vacuum optimization for tables with no
indexes was introduced.

Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: http://postgr.es/m/CAD21AoBL8m6B9GSzQfYxVaEgvD7-Kr3AJaS-hJPHC+avm-29zw@mail.gmail.com
Backpatch-through: 17
src/backend/access/heap/vacuumlazy.c