Fix deduplication "single value" strategy bug.
authorPeter Geoghegan <pg@bowt.ie>
Fri, 19 Jun 2020 15:57:24 +0000 (08:57 -0700)
committerPeter Geoghegan <pg@bowt.ie>
Fri, 19 Jun 2020 15:57:24 +0000 (08:57 -0700)
commitbe14f884d57bc9c8ec8415edafea35ba5d31af59
treec6025c8b20efcc61eb4affcdbc111e159e7a35ec
parentf9e9704f09daf882f5a1cf1fbe3f5a3150ae2bb9
Fix deduplication "single value" strategy bug.

It was possible for deduplication's single value strategy to mistakenly
believe that a very small duplicate tuple counts as one of the six large
tuples that it aims to leave behind after the page finally splits.  This
could cause slightly suboptimal space utilization with very low
cardinality indexes, though only under fairly narrow conditions.

To fix, be particular about what kind of tuple counts as a
maxpostingsize-capped tuple.  This avoids confusion in the event of a
small tuple that gets "wedged" between two large tuples, where all
tuples on the page are duplicates of the same value.

Discussion: https://postgr.es/m/CAH2-Wz=Y+sgSFc-O3LpiZX-POx2bC+okec2KafERHuzdVa7-rQ@mail.gmail.com
Backpatch: 13-, where deduplication was introduced (by commit 0d861bbb)
src/backend/access/nbtree/nbtdedup.c
src/backend/access/nbtree/nbtsort.c
src/backend/access/nbtree/nbtxlog.c
src/include/access/nbtree.h