Skip to content

Commit a7b9d24

Browse files
Make deduplication use number of key attributes.
Use IndexRelationGetNumberOfKeyAttributes() rather than IndexRelationGetNumberOfAttributes() when determining whether or not two index tuples are suitable for merging together into a single posting list tuple. This is a little bit tidier. It brings affected code in nbtdedup.c a little closer to similar, related code in nbtsplitloc.c.
1 parent 9950c8a commit a7b9d24

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/backend/access/nbtree/nbtdedup.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ _bt_dedup_one_page(Relation rel, Buffer buf, Relation heapRel,
6868
int ndeletable = 0;
6969
Size pagesaving = 0;
7070
bool singlevalstrat = false;
71-
int natts = IndexRelationGetNumberOfAttributes(rel);
71+
int nkeyatts = IndexRelationGetNumberOfKeyAttributes(rel);
7272

7373
/*
7474
* We can't assume that there are no LP_DEAD items. For one thing, VACUUM
@@ -182,7 +182,7 @@ _bt_dedup_one_page(Relation rel, Buffer buf, Relation heapRel,
182182
_bt_dedup_start_pending(state, itup, offnum);
183183
}
184184
else if (state->deduplicate &&
185-
_bt_keep_natts_fast(rel, state->base, itup) > natts &&
185+
_bt_keep_natts_fast(rel, state->base, itup) > nkeyatts &&
186186
_bt_dedup_save_htid(state, itup))
187187
{
188188
/*
@@ -519,19 +519,19 @@ static bool
519519
_bt_do_singleval(Relation rel, Page page, BTDedupState state,
520520
OffsetNumber minoff, IndexTuple newitem)
521521
{
522-
int natts = IndexRelationGetNumberOfAttributes(rel);
522+
int nkeyatts = IndexRelationGetNumberOfKeyAttributes(rel);
523523
ItemId itemid;
524524
IndexTuple itup;
525525

526526
itemid = PageGetItemId(page, minoff);
527527
itup = (IndexTuple) PageGetItem(page, itemid);
528528

529-
if (_bt_keep_natts_fast(rel, newitem, itup) > natts)
529+
if (_bt_keep_natts_fast(rel, newitem, itup) > nkeyatts)
530530
{
531531
itemid = PageGetItemId(page, PageGetMaxOffsetNumber(page));
532532
itup = (IndexTuple) PageGetItem(page, itemid);
533533

534-
if (_bt_keep_natts_fast(rel, newitem, itup) > natts)
534+
if (_bt_keep_natts_fast(rel, newitem, itup) > nkeyatts)
535535
return true;
536536
}
537537

0 commit comments

Comments
 (0)