Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd299df

Browse files
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.com
1 parente5adcb7 commitdd299df

29 files changed

+1619
-559
lines changed

‎contrib/amcheck/expected/check_btree.out

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,12 @@ SELECT bt_index_parent_check('bttest_multi_idx', true);
130130
--
131131
INSERT INTO delete_test_table SELECT i, 1, 2, 3 FROM generate_series(1,80000) i;
132132
ALTER TABLE delete_test_table ADD PRIMARY KEY (a,b,c,d);
133+
-- Delete many entries, and vacuum. This causes page deletions.
133134
DELETE FROM delete_test_table WHERE a > 40000;
134135
VACUUM delete_test_table;
135-
DELETE FROM delete_test_table WHERE a > 10;
136+
-- Delete most entries, and vacuum, deleting internal pages and creating "fast
137+
-- root"
138+
DELETE FROM delete_test_table WHERE a < 79990;
136139
VACUUM delete_test_table;
137140
SELECT bt_index_parent_check('delete_test_table_pkey', true);
138141
bt_index_parent_check

‎contrib/amcheck/sql/check_btree.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ SELECT bt_index_parent_check('bttest_multi_idx', true);
8282
--
8383
INSERT INTO delete_test_tableSELECT i,1,2,3FROM generate_series(1,80000) i;
8484
ALTERTABLE delete_test_table ADDPRIMARY KEY (a,b,c,d);
85+
-- Delete many entries, and vacuum. This causes page deletions.
8586
DELETEFROM delete_test_tableWHERE a>40000;
8687
VACUUM delete_test_table;
87-
DELETEFROM delete_test_tableWHERE a>10;
88+
-- Delete most entries, and vacuum, deleting internal pages and creating "fast
89+
-- root"
90+
DELETEFROM delete_test_tableWHERE a<79990;
8891
VACUUM delete_test_table;
8992
SELECT bt_index_parent_check('delete_test_table_pkey', true);
9093

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp