Re: Incorrect result of bitmap heap scan.
Matthias van de Meent <boekewurm+postgres@gmail.com>
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
To: "Core Studios Inc." <corestudiosinc@gmail.com>
Cc: Peter Geoghegan <pg@bowt.ie>, Tom Lane <tgl@sss.pgh.pa.us>,
Andres Freund <andres@anarazel.de>, Andrew Dunstan <andrew@dunslane.net>,
Melanie Plageman <melanieplageman@gmail.com>, Thomas Munro <thomas.munro@gmail.com>,
Konstantin Knizhnik <knizhnik@garret.ru>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Alexander Kuzmenkov <akuzmenkov@timescale.com>
Date: 2025-09-16T12:56:09Z
Lists: pgsql-hackers
On Tue, 16 Sept 2025 at 13:57, Core Studios Inc. <corestudiosinc@gmail.com> wrote: > > Hello, > > We noticed a sustained increased in IO Wait of read queries after > upgrading from 13.13 to 13.21. Eventually, we narrowed it down to a > spike in index_blocks_read of a certain table where Bitmap Heap Scans do > happen. > > Do you think that this change (i.e. removing the optimization) could be > what caused this regression? I'm quite sure that the IOs for a Bitmap Heap Scan (which is the node that now may see increased IO) count towards the table's IO statistics (e.g. pg_stat_all_tables, heap_blks_read), not the index (e.g. pg_stat_all_indexes, idx_blcks_read). Only "Index Scan" (and Bitmap IS, and IOS) nodes can count their IO toward their relative indexes, and the executor code for those nodes was not modified in this bugfix. Note that before the removal of the VM-only option, these "bitmap only" nodes could return incorrect results, and thus that "bitmap-only scan" wasn't really a valid optimization. Also note that neither the "optimization" nor the fix modified any part or dependency of the planner, so any changes in plans must have been caused by other changes in the system as a whole (such as updated table statistics, and (unlikely) other backported bugfixes). Kind regards, Matthias van de Meent Databricks
Commits
-
Add test for HeapBitmapScan's broken skip_fetch optimization
- 24da5b239a4b 18.0 landed
-
Remove HeapBitmapScan's skip_fetch optimization
- 459e7bf8e2f8 18.0 landed
- b9ec8125d167 13.21 landed
- 4934d38759cd 14.18 landed
- 77d90d6d6334 15.13 landed
- 980727b84107 16.9 landed
- 78cb2466f752 17.5 landed
-
Allow bitmap scans to operate as index-only scans when possible.
- 7c70996ebf09 11.0 cited