Commit a7b9d24e authored by Peter Geoghegan's avatar Peter Geoghegan

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.
parent 9950c8aa
...@@ -68,7 +68,7 @@ _bt_dedup_one_page(Relation rel, Buffer buf, Relation heapRel, ...@@ -68,7 +68,7 @@ _bt_dedup_one_page(Relation rel, Buffer buf, Relation heapRel,
int ndeletable = 0; int ndeletable = 0;
Size pagesaving = 0; Size pagesaving = 0;
bool singlevalstrat = false; bool singlevalstrat = false;
int natts = IndexRelationGetNumberOfAttributes(rel); int nkeyatts = IndexRelationGetNumberOfKeyAttributes(rel);
/* /*
* We can't assume that there are no LP_DEAD items. For one thing, VACUUM * 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, ...@@ -182,7 +182,7 @@ _bt_dedup_one_page(Relation rel, Buffer buf, Relation heapRel,
_bt_dedup_start_pending(state, itup, offnum); _bt_dedup_start_pending(state, itup, offnum);
} }
else if (state->deduplicate && else if (state->deduplicate &&
_bt_keep_natts_fast(rel, state->base, itup) > natts && _bt_keep_natts_fast(rel, state->base, itup) > nkeyatts &&
_bt_dedup_save_htid(state, itup)) _bt_dedup_save_htid(state, itup))
{ {
/* /*
...@@ -519,19 +519,19 @@ static bool ...@@ -519,19 +519,19 @@ static bool
_bt_do_singleval(Relation rel, Page page, BTDedupState state, _bt_do_singleval(Relation rel, Page page, BTDedupState state,
OffsetNumber minoff, IndexTuple newitem) OffsetNumber minoff, IndexTuple newitem)
{ {
int natts = IndexRelationGetNumberOfAttributes(rel); int nkeyatts = IndexRelationGetNumberOfKeyAttributes(rel);
ItemId itemid; ItemId itemid;
IndexTuple itup; IndexTuple itup;
itemid = PageGetItemId(page, minoff); itemid = PageGetItemId(page, minoff);
itup = (IndexTuple) PageGetItem(page, itemid); itup = (IndexTuple) PageGetItem(page, itemid);
if (_bt_keep_natts_fast(rel, newitem, itup) > natts) if (_bt_keep_natts_fast(rel, newitem, itup) > nkeyatts)
{ {
itemid = PageGetItemId(page, PageGetMaxOffsetNumber(page)); itemid = PageGetItemId(page, PageGetMaxOffsetNumber(page));
itup = (IndexTuple) PageGetItem(page, itemid); itup = (IndexTuple) PageGetItem(page, itemid);
if (_bt_keep_natts_fast(rel, newitem, itup) > natts) if (_bt_keep_natts_fast(rel, newitem, itup) > nkeyatts)
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment