forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdd299df
committed
Make heap TID a tiebreaker nbtree index column.
Make nbtree treat all index tuples as having a heap TID attribute.Index searches can distinguish duplicates by heap TID, since heap TID isalways guaranteed to be unique. This general approach has numerousbenefits for performance, and is prerequisite to teaching VACUUM toperform "retail index tuple deletion".Naively adding a new attribute to every pivot tuple has unacceptableoverhead (it bloats internal pages), so suffix truncation of pivottuples is added. This will usually truncate away the "extra" heap TIDattribute from pivot tuples during a leaf page split, and may alsotruncate away additional user attributes. This can increase fan-out,especially in a multi-column index. Truncation can only occur at theattribute granularity, which isn't particularly effective, but workswell enough for now. A future patch may add support for truncating"within" text attributes by generating truncated key values using newopclass infrastructure.Only new indexes (BTREE_VERSION 4 indexes) will have insertions thattreat heap TID as a tiebreaker attribute, or will have pivot tuplesundergo suffix truncation during a leaf page split (on-diskcompatibility with versions 2 and 3 is preserved). Upgrades to version4 cannot be performed on-the-fly, unlike upgrades from version 2 toversion 3. contrib/amcheck continues to work with version 2 and 3indexes, while also enforcing stricter invariants when verifying version4 indexes. These stricter invariants are the same invariants describedby "3.1.12 Sequencing" from the Lehman and Yao paper.A later patch will enhance the logic used by nbtree to pick a splitpoint. This patch is likely to negatively impact performance withoutsmarter choices around the precise point to split leaf pages at. Makingthese two mostly-distinct sets of enhancements into distinct commitsseems like it might clarify their design, even though neither commit isparticularly useful on its own.The maximum allowed size of new tuples is reduced by an amount equal tothe space required to store an extra MAXALIGN()'d TID in a new high keyduring leaf page splits. The user-facing definition of the "1/3 of apage" restriction is already imprecise, and so does not need to berevised. However, there should be a compatibility note in the v12release notes.Author: Peter GeogheganReviewed-By: Heikki Linnakangas, Alexander KorotkovDiscussion:https://postgr.es/m/CAH2-WzkVb0Kom=R+88fDFb=JSxZMFvbHVC6Mn9LJ2n=X=kS-Uw@mail.gmail.com1 parente5adcb7 commitdd299df
File tree
29 files changed
+1619
-559
lines changed- contrib
- amcheck
- expected
- sql
- pageinspect
- expected
- pgstattuple/expected
- doc/src/sgml
- src
- backend
- access
- common
- nbtree
- rmgrdesc
- utils/sort
- include/access
- test/regress
- expected
- sql
29 files changed
+1619
-559
lines changedLines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
130 | 130 |
| |
131 | 131 |
| |
132 | 132 |
| |
| 133 | + | |
133 | 134 |
| |
134 | 135 |
| |
135 |
| - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
136 | 139 |
| |
137 | 140 |
| |
138 | 141 |
| |
|
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
82 | 82 |
| |
83 | 83 |
| |
84 | 84 |
| |
| 85 | + | |
85 | 86 |
| |
86 | 87 |
| |
87 |
| - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
88 | 91 |
| |
89 | 92 |
| |
90 | 93 |
| |
|
0 commit comments
Comments
(0)