Re: Making all nbtree entries unique by having heap TIDs participate in comparisons
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>,
Robert Haas <robertmhaas@gmail.com>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Alexander Korotkov <a.korotkov@postgrespro.ru>,
Thomas Munro <thomas.munro@enterprisedb.com>, Claudio Freire <klaussfreire@gmail.com>, Anastasia Lubennikova <a.lubennikova@postgrespro.ru>, "Andrey V. Lepikhov" <a.lepikhov@postgrespro.ru>
Date: 2019-03-07T09:06:24Z
Lists: pgsql-hackers
On Wed, Mar 6, 2019 at 11:41 PM Heikki Linnakangas <hlinnaka@iki.fi> wrote: > I don't understand it :-(. I guess that's valuable feedback on its own. > I'll spend more time reading the code around that, but meanwhile, if you > can think of a simpler way to explain it in the comments, that'd be good. One more thing on this: If you force bitmap index scans (by disabling index-only scans and index scans with the "enable_" GUCs), then you get EXPLAIN (ANALYZE, BUFFERS) instrumentation for the index alone (and the heap, separately). No visibility map accesses, which obscure the same numbers for a similar index-only scan. You can then observe that most searches of a single value will touch the bare minimum number of index pages. For example, if there are 3 levels in the index, you should access only 3 index pages total, unless there are literally hundreds of matches, and cannot avoid storing them on more than one leaf page. You'll see that the scan touches the minimum possible number of index pages, because of: * Many duplicates strategy. (Not single value strategy, which I incorrectly mentioned in relation to this earlier.) * The !minusinfykey optimization, which ensures that we go to the right of an otherwise-equal pivot tuple in an internal page, rather than left. * The "continuescan" high key patch, which ensures that the scan doesn't go to the right from the first leaf page to try to find even more matches. The high key on the same leaf page will indicate that the scan is over, without actually visiting the sibling. (Again, I'm assuming that your search is for a single value.) -- Peter Geoghegan
Commits
-
Add "split after new tuple" nbtree optimization.
- f21668f328c8 12.0 landed
-
Add nbtree high key "continuescan" optimization.
- 29b64d1de7c7 12.0 landed
-
Allow amcheck to re-find tuples using new search.
- c1afd175b5b2 12.0 landed
-
Consider secondary factors during nbtree splits.
- fab250243387 12.0 landed
-
Make heap TID a tiebreaker nbtree index column.
- dd299df8189b 12.0 landed
-
Refactor nbtree insertion scankeys.
- e5adcb789d80 12.0 landed
-
Redesign the partition dependency mechanism.
- 1d92a0c9f7dd 12.0 cited
-
Avoid unnecessary palloc overhead in _bt_first(). The temporary
- d961a5689966 8.1.0 cited