postgresql/src
Peter Geoghegan fab2502433 Consider secondary factors during nbtree splits.
Teach nbtree to give some consideration to how "distinguishing"
candidate leaf page split points are.  This should not noticeably affect
the balance of free space within each half of the split, while still
making suffix truncation truncate away significantly more attributes on
average.

The logic for choosing a leaf split point now uses a fallback mode in
the case where the page is full of duplicates and it isn't possible to
find even a minimally distinguishing split point.  When the page is full
of duplicates, the split should pack the left half very tightly, while
leaving the right half mostly empty.  Our assumption is that logical
duplicates will almost always be inserted in ascending heap TID order
with v4 indexes.  This strategy leaves most of the free space on the
half of the split that will likely be where future logical duplicates of
the same value need to be placed.

The number of cycles added is not very noticeable.  This is important
because deciding on a split point takes place while at least one
exclusive buffer lock is held.  We avoid using authoritative insertion
scankey comparisons to save cycles, unlike suffix truncation proper.  We
use a faster binary comparison instead.

Note that even pg_upgrade'd v3 indexes make use of these optimizations.
Benchmarking has shown that even v3 indexes benefit, despite the fact
that suffix truncation will only truncate non-key attributes in INCLUDE
indexes.  Grouping relatively similar tuples together is beneficial in
and of itself, since it reduces the number of leaf pages that must be
accessed by subsequent index scans.

Author: Peter Geoghegan
Reviewed-By: Heikki Linnakangas
Discussion: https://postgr.es/m/CAH2-WzmmoLNQOj9mAD78iQHfWLJDszHEDrAzGTUMG3mVh5xWPw@mail.gmail.com
2019-03-20 10:12:19 -07:00
..
backend Consider secondary factors during nbtree splits. 2019-03-20 10:12:19 -07:00
bin Remove unused macro 2019-03-18 09:13:08 +01:00
common Refactor more code logic to update the control file 2019-03-18 12:59:35 +09:00
fe_utils More unconstify use 2019-02-13 11:50:16 +01:00
include Consider secondary factors during nbtree splits. 2019-03-20 10:12:19 -07:00
interfaces Restructure libpq's handling of send failures. 2019-03-19 16:20:28 -04:00
makefiles Move port-specific parts of with_temp_install to port makefile. 2019-02-04 18:54:56 +00:00
pl PL/Tcl: Improve trigger tests organization 2019-03-15 12:42:07 +01:00
port Fix error handling of readdir() port implementation on first file lookup 2019-03-04 09:49:06 +09:00
template
test Make heap TID a tiebreaker nbtree index column. 2019-03-20 10:04:01 -07:00
timezone More unconstify use 2019-02-13 11:50:16 +01:00
tools Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
tutorial SQL comment: remove extra word in heading comment 2019-01-25 18:57:21 -05:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Revert attempts to use POPCNT etc instructions 2019-02-15 16:32:30 -03:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00