postgresql/src
Peter Geoghegan e3899ffd8b Fix pathological nbtree split point choice issue.
Specific ever-decreasing insertion patterns could cause successive
unbalanced nbtree page splits.  Problem cases involve a large group of
duplicates to the left, and ever-decreasing insertions to the right.

To fix, detect the situation by considering the newitem offset before
performing a split using nbtsplitloc.c's "many duplicates" strategy.  If
the new item was inserted just to the right of our provisional "many
duplicates" split point, infer ever-decreasing insertions and fall back
on a 50:50 (space delta optimal) split.  This seems to barely affect
cases that already had acceptable space utilization.

An alternative fix also seems possible.  Instead of changing
nbtsplitloc.c split choice logic, we could instead teach _bt_truncate()
to generate a new value for new high keys by interpolating from the
lastleft and firstright key values.  That would certainly be a more
elegant fix, but it isn't suitable for backpatching.

Discussion: https://postgr.es/m/CAH2-WznCNvhZpxa__GqAa1fgQ9uYdVc=_apArkW2nc-K3O7_NA@mail.gmail.com
Backpatch: 12-, where the nbtree page split enhancements were introduced.
2019-07-15 13:19:13 -07:00
..
backend Fix pathological nbtree split point choice issue. 2019-07-15 13:19:13 -07:00
bin Revive test of concurrent OID generation. 2019-07-13 13:34:22 -07:00
common Use consistent style for checking return from system calls 2019-07-07 15:28:49 +02:00
fe_utils Use appendStringInfoString and appendPQExpBufferStr where possible 2019-07-04 13:01:13 +12:00
include Represent Lists as expansible arrays, not chains of cons-cells. 2019-07-15 13:41:58 -04:00
interfaces Fix inconsistencies in the code 2019-07-08 13:15:09 +09:00
makefiles Remove support for non-ELF BSD systems 2019-07-01 23:56:20 +01:00
pl Represent Lists as expansible arrays, not chains of cons-cells. 2019-07-15 13:41:58 -04:00
port Stamp HEAD as 13devel. 2019-07-01 12:50:55 -04:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Add gen_random_uuid function 2019-07-14 14:30:27 +02:00
timezone Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
tools Fix some inconsistencies in MSVC scripts 2019-07-13 16:51:31 +09:00
tutorial Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Remove support for non-ELF BSD systems 2019-07-01 23:56:20 +01:00
Makefile.shlib Remove support for non-ELF BSD systems 2019-07-01 23:56:20 +01:00
nls-global.mk Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00