pgsql: Add nbtree high key "continuescan" optimization.

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема pgsql: Add nbtree high key "continuescan" optimization.
Дата
Msg-id E1h7kyF-0005Fd-CO@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/29b64d1de7c77ffb5cb10696693e6ed8a6fc481c

Modified Files
--------------
src/backend/access/nbtree/nbtsearch.c |  87 +++++++++++++++++++++++---
src/backend/access/nbtree/nbtutils.c  | 113 +++++++++++++++-------------------
src/include/access/nbtree.h           |   5 +-
3 files changed, 128 insertions(+), 77 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: pgsql: Improve format of code and some error messages in pg_checksums
Следующее
От: Peter Geoghegan
Дата:
Сообщение: pgsql: Suppress DETAIL output from an event_trigger test.