]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Make deduplication use number of key attributes.
authorPeter Geoghegan <pg@bowt.ie>
Sun, 29 Mar 2020 03:25:03 +0000 (20:25 -0700)
committerPeter Geoghegan <pg@bowt.ie>
Sun, 29 Mar 2020 03:25:03 +0000 (20:25 -0700)
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.

src/backend/access/nbtree/nbtdedup.c

index 2434ce134bf696f2b3c2bb8a32fc8122b63062c7..b20faf693daa401c462d75ef61424d533eea69d6 100644 (file)
@@ -68,7 +68,7 @@ _bt_dedup_one_page(Relation rel, Buffer buf, Relation heapRel,
        int                     ndeletable = 0;
        Size            pagesaving = 0;
        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
@@ -182,7 +182,7 @@ _bt_dedup_one_page(Relation rel, Buffer buf, Relation heapRel,
                        _bt_dedup_start_pending(state, itup, offnum);
                }
                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))
                {
                        /*
@@ -519,19 +519,19 @@ static bool
 _bt_do_singleval(Relation rel, Page page, BTDedupState state,
                                 OffsetNumber minoff, IndexTuple newitem)
 {
-       int                     natts = IndexRelationGetNumberOfAttributes(rel);
+       int                     nkeyatts = IndexRelationGetNumberOfKeyAttributes(rel);
        ItemId          itemid;
        IndexTuple      itup;
 
        itemid = PageGetItemId(page, minoff);
        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));
                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;
        }