postgresql/src/backend/access
Peter Geoghegan 29b64d1de7 Add nbtree high key "continuescan" optimization.
Teach nbtree forward index scans to check the high key before moving to
the right sibling page in the hope of finding that it isn't actually
necessary to do so.  The new check may indicate that the scan definitely
cannot find matching tuples to the right, ending the scan immediately.
We already opportunistically force a similar "continuescan orientated"
key check of the final non-pivot tuple when it's clear that it cannot be
returned to the scan due to being dead-to-all.  The new high key check
is complementary.

The new approach for forward scans is more effective than checking the
final non-pivot tuple, especially with composite indexes and non-unique
indexes.  The improvements to the logic for picking a split point added
by commit fab25024 make it likely that relatively dissimilar high keys
will appear on a page.  A distinguishing key value that can only appear
on non-pivot tuples on the right sibling page will often be present in
leaf page high keys.

Since forcing the final item to be key checked no longer makes any
difference in the case of forward scans, the existing extra key check is
now only used for backwards scans.  Backward scans continue to
opportunistically check the final non-pivot tuple, which is actually the
first non-pivot tuple on the page (not the last).

Note that even pg_upgrade'd v3 indexes make use of this optimization.

Author: Peter Geoghegan, Heikki Linnakangas
Reviewed-By: Heikki Linnakangas
Discussion: https://postgr.es/m/CAH2-WzkOmUduME31QnuTFpimejuQoiZ-HOf0pOWeFZNhTMctvA@mail.gmail.com
2019-03-23 11:01:53 -07:00
..
brin More unconstify use 2019-02-13 11:50:16 +01:00
common Make heap TID a tiebreaker nbtree index column. 2019-03-20 10:04:01 -07:00
gin Fix misc typos in comments. 2019-01-23 13:39:00 +02:00
gist Fix bug in the GiST vacuum's 2nd stage. 2019-03-22 14:11:46 +02:00
hash Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
heap Fold vacuum's 'int options' parameter into VacuumParams. 2019-03-18 13:57:33 -04:00
index tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
nbtree Add nbtree high key "continuescan" optimization. 2019-03-23 11:01:53 -07:00
rmgrdesc Delete empty pages during GiST VACUUM. 2019-03-22 13:21:45 +02:00
spgist Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
table tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
tablesample tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
transam Refactor more code logic to update the control file 2019-03-18 12:59:35 +09:00
Makefile Introduce access/{table.h, relation.h}, for generic functions from heapam.h. 2019-01-21 10:51:36 -08:00