Re: Making Row Comparison NULL row member handling more robust during skip scans
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-06-27T21:35:50Z
Lists: pgsql-hackers
Attachments
- v4-0002-Make-row-compares-robust-during-scans-with-arrays.patch (application/octet-stream) patch v4-0002
- v4-0001-Make-handling-of-redundant-nbtree-keys-more-robus.patch (application/octet-stream) patch v4-0001
On Wed, Jun 25, 2025 at 5:44 PM Peter Geoghegan <pg@bowt.ie> wrote: > Correction: there *is* a live bug like this on Postgres 18/HEAD, which > involves simple scalar inequalities with an incomplete opfamily. > Attached v3 fixes the bug in its new 0001-* patch. Attached is v4, which is largely just a polished version of v3. It has improved comments and more worked out commit messages. Plus the second patch (the row compare patch) now teaches _bt_first to fully rely on scan key requiredness markings, just like with other scan keys. Current plan is to commit these two some time next week. It'd be nice to get some code review before then, or any kind of input on my general direction. Note again that the approach I've taken to fixing the bug *adds a performance optimization*. It will fix the row compare performance problem described on a thread from February of this year: https://www.postgresql.org/message-id/flat/BLAPR09MB64993673A034EE93C6C6F4B6CCF62%40BLAPR09MB6499.namprd09.prod.outlook.com It will *also* fix the row compare performance problem that Tom complained about last year, which included its own test case: https://postgr.es/m/66001.1715455158@sss.pgh.pa.us I am aware that this all sounds quite odd. Yes, I'm proposing a bug fix that improves performance in what must seem like fairly tangential cases. As I went into already, it really did just work out that way. I had forgotten about the two threads I'm referencing here until I saw references to each of them in my skip scan project notes. I'm mentioning them on the thread now in case they're useful breadcrumbs for somebody down that revisits this thread in the future. -- Peter Geoghegan
Commits
-
Make row compares robust during nbtree array scans.
- bd3f59fdb717 19 (unreleased) landed
- 4cb889d21f3d 18.0 landed
-
Make handling of redundant nbtree keys more robust.
- f09816a0a7c1 19 (unreleased) landed
- 7c365eb50429 18.0 landed
-
Revert "nbtree: Remove useless row compare arg."
- dd2ce3792754 18.0 cited
-
nbtree: Remove useless row compare arg.
- 54c6ea8c81db 18.0 cited
-
Prevent premature nbtree array advancement.
- 5f4d98d4f371 18.0 cited
-
Improvements and fixes for e0b1ee17dc
- 7e6fb5da41d8 17.0 cited
-
Fix incorrect handling of NULL index entries in indexed ROW() comparisons.
- a298a1e06fb0 9.6.0 cited
-
Fix btree stop-at-nulls logic properly.
- 882368e854b6 9.2.0 cited
-
Stop btree indexscans upon reaching nulls in either direction.
- 6980f817e83c 9.2.0 cited