postgresql/src/include/access
Peter Geoghegan cf2acaf4dc Deprecate nbtree's BTP_HAS_GARBAGE flag.
Streamline handling of the various strategies that we have to avoid a
page split in nbtinsert.c.  When it looks like a leaf page is about to
overflow, we now perform deleting LP_DEAD items and deduplication in one
central place.  This greatly simplifies _bt_findinsertloc().

This has an independently useful consequence: nbtree no longer relies on
the BTP_HAS_GARBAGE page level flag/hint for anything important.  We
still set and unset the flag in the same way as before, but it's no
longer treated as a gating condition when considering if we should check
for already-set LP_DEAD bits.  This happens at the point where the page
looks like it might have to be split anyway, so simply checking the
LP_DEAD bits in passing is practically free.  This avoids missing
LP_DEAD bits just because the page-level hint is unset, which is
probably reasonably common (e.g. it happens when VACUUM unsets the
page-level flag without actually removing index tuples whose LP_DEAD-bit
was set recently, after the VACUUM operation began but before it reached
the leaf page in question).

Note that this isn't a big behavioral change compared to PostgreSQL 13.
We were already checking for set LP_DEAD bits regardless of whether the
BTP_HAS_GARBAGE page level flag was set before we considered doing a
deduplication pass.  This commit only goes slightly further by doing the
same check for all indexes, even indexes where deduplication won't be
performed.

We don't completely remove the BTP_HAS_GARBAGE flag.  We still rely on
it as a gating condition with pg_upgrade'd indexes from before B-tree
version 4/PostgreSQL 12.  That makes sense because we sometimes have to
make a choice among pages full of duplicates when inserting a tuple with
pre version 4 indexes.  It probably still pays to avoid accessing the
line pointer array of a page there, since it won't yet be clear whether
we'll insert on to the page in question at all, let alone split it as a
result.

Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Victor Yegorov <vyegorov@gmail.com>
Discussion: https://postgr.es/m/CAH2-Wz%3DYpc1PDdk8OVJDChGJBjT06%3DA0Mbv9HyTLCsOknGcUFg%40mail.gmail.com
2020-11-17 09:45:56 -08:00
..
amapi.h Invent "amadjustmembers" AM method for validating opclass members. 2020-08-01 17:12:47 -04:00
amvalidate.h Invent "amadjustmembers" AM method for validating opclass members. 2020-08-01 17:12:47 -04:00
attmap.h Fix assorted typos 2020-03-31 16:00:06 +02:00
attnum.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
brin.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
brin_internal.h Implement operator class parameters 2020-03-30 19:17:23 +03:00
brin_page.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
brin_pageops.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
brin_revmap.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
brin_tuple.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
brin_xlog.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
bufmask.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
clog.h Defer flushing of SLRU files. 2020-09-25 19:00:15 +12:00
commit_ts.h Defer flushing of SLRU files. 2020-09-25 19:00:15 +12:00
detoast.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
genam.h Redefine pg_class.reltuples to be -1 before the first VACUUM or ANALYZE. 2020-08-30 12:21:51 -04:00
generic_xlog.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
gin.h Implement operator class parameters 2020-03-30 19:17:23 +03:00
gin_private.h Invent "amadjustmembers" AM method for validating opclass members. 2020-08-01 17:12:47 -04:00
ginblock.h snapshot scalability: Don't compute global horizons while building snapshots. 2020-08-12 16:03:49 -07:00
ginxlog.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
gist.h Fix some typos 2020-11-14 11:43:10 +09:00
gist_private.h Add support for building GiST index by sorting. 2020-09-17 11:33:40 +03:00
gistscan.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
gistxlog.h Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
hash.h Invent "amadjustmembers" AM method for validating opclass members. 2020-08-01 17:12:47 -04:00
hash_xlog.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
heapam.h Add additional information in the vacuum error context. 2020-08-26 09:40:52 +05:30
heapam_xlog.h C comment: remove mention of use of t_hoff WAL structure member 2020-08-31 13:58:00 -04:00
heaptoast.h tableam: New callback relation_fetch_toast_slice. 2020-01-07 14:36:38 -05:00
hio.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
htup.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
htup_details.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
itup.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
multixact.h Extend amcheck to check heap pages. 2020-10-22 08:44:18 -04:00
nbtree.h Deprecate nbtree's BTP_HAS_GARBAGE flag. 2020-11-17 09:45:56 -08:00
nbtxlog.h Adjust "root of to-be-deleted subtree" function. 2020-05-11 11:01:07 -07:00
parallel.h Allow vacuum command to process indexes in parallel. 2020-01-20 07:57:49 +05:30
printsimple.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
printtup.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
relation.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
reloptions.h Implement operator class parameters 2020-03-30 19:17:23 +03:00
relscan.h Allocate consecutive blocks during parallel seqscans 2020-07-26 21:02:45 +12:00
rewriteheap.h Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
rmgr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
rmgrlist.h Add deduplication to nbtree. 2020-02-26 13:05:30 -08:00
sdir.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
session.h Fix typo. 2020-01-13 14:44:55 +05:30
skey.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
slru.h Defer flushing of SLRU files. 2020-09-25 19:00:15 +12:00
spgist.h Invent "amadjustmembers" AM method for validating opclass members. 2020-08-01 17:12:47 -04:00
spgist_private.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
spgxlog.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
stratnum.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
subtrans.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
syncscan.h Move syncscan.c to src/backend/access/common. 2020-07-29 16:59:33 +12:00
sysattr.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
table.h Improve handling of dropped relations for REINDEX DATABASE/SCHEMA/SYSTEM 2020-09-02 09:08:12 +09:00
tableam.h Implement streaming mode in ReorderBuffer. 2020-08-08 07:47:06 +05:30
timeline.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
toast_helper.h Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
toast_internals.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
transam.h snapshot scalability: cache snapshots using a xact completion counter. 2020-08-17 21:08:30 -07:00
tsmapi.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tupconvert.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tupdesc.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tupdesc_details.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tupmacs.h Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
twophase.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
twophase_rmgr.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
valid.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
visibilitymap.h Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
xact.h doc: improve description of synchronous_commit modes 2020-10-15 15:15:29 -04:00
xlog.h Remove non-fast promotion. 2020-07-29 21:24:26 +09:00
xlog_internal.h Correct several behavior descriptions in comments. 2020-08-15 20:21:52 -07:00
xlogarchive.h Move routine definitions of xlogarchive.c to a new header file 2020-03-31 15:33:04 +09:00
xlogdefs.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
xloginsert.h Add support for building GiST index by sorting. 2020-09-17 11:33:40 +03:00
xlogreader.h Fix typos. 2020-11-03 08:38:27 +05:30
xlogrecord.h Immediately WAL-log subtransaction and top-level XID association. 2020-07-20 08:48:26 +05:30
xlogutils.h Adjust walsender usage of xlogreader, simplify APIs 2020-05-13 12:17:08 -04:00