Subject: pgsql: Remove HeapBitmapScan's skip_fetch optimization

From: Andres Freund <[email-masked]>
Date: Wed, 02 Apr 2025 19:35:39 +0000

Remove HeapBitmapScan's skip_fetch optimization

The optimization does not take the removal of TIDs by a concurrent vacuum into
account. The concurrent vacuum can remove dead TIDs and make pages ALL_VISIBLE
while those dead TIDs are referenced in the bitmap. This can lead to a
skip_fetch scan returning too many tuples.

It likely would be possible to implement this optimization safely, but we
don't have the necessary infrastructure in place. Nor is it clear that it's
worth building that infrastructure, given how limited the skip_fetch
optimization is.

In the backbranches we just disable the optimization by always passing
need_tuples=true to table_beginscan_bm(). We can't perform API/ABI changes in
the backbranches and we want to make the change as minimal as possible.

Author: Matthias van de Meent <[email-masked]>
Reported-By: Konstantin Knizhnik <[email-masked]>
Discussion: https://postgr.es/m/[email-masked]
Backpatch-through: 13

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4934d38759cdb65965db4ccf10aa767d9bee5e00

Modified Files
--------------
src/backend/executor/nodeBitmapHeapscan.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)