pgsql: Remove HeapBitmapScan's skip_fetch optimization

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove HeapBitmapScan's skip_fetch optimization
Date: 2025-04-02 19:35:39
Message-ID: E1u03sB-002Ld3-11@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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 <boekewurm+postgres(at)gmail(dot)com>
Reported-By: Konstantin Knizhnik <knizhnik(at)garret(dot)ru>
Discussion: https://postgr.es/m/CAEze2Wg3gXXZTr6_rwC+s4-o2ZVFB5F985uUSgJTsECx6AmGcQ@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b9ec8125d167df445c7a310f6b5aa1448009cbaa

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

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-04-02 20:18:39 pgsql: Remove unnecessary type violation in tsvectorrecv().
Previous Message Tom Lane 2025-04-02 18:06:23 pgsql: Change SQL-language functions to use the plan cache.