Commit f0e72a25 authored by Robert Haas's avatar Robert Haas

Improve handling of dead tuples in hash indexes.

When squeezing a bucket during vacuum, it's not necessary to retain
any tuples already marked as dead, so ignore them when deciding which
tuples must be moved in order to empty a bucket page.  Similarly, when
splitting a bucket, relocating dead tuples to the new bucket is a
waste of effort; instead, just ignore them.

Amit Kapila, reviewed by me.  Testing help provided by Ashutosh
Sharma.
parent 650b9670
...@@ -656,6 +656,10 @@ _hash_squeezebucket(Relation rel, ...@@ -656,6 +656,10 @@ _hash_squeezebucket(Relation rel,
IndexTuple itup; IndexTuple itup;
Size itemsz; Size itemsz;
/* skip dead tuples */
if (ItemIdIsDead(PageGetItemId(rpage, roffnum)))
continue;
itup = (IndexTuple) PageGetItem(rpage, itup = (IndexTuple) PageGetItem(rpage,
PageGetItemId(rpage, roffnum)); PageGetItemId(rpage, roffnum));
itemsz = IndexTupleDSize(*itup); itemsz = IndexTupleDSize(*itup);
......
...@@ -811,6 +811,10 @@ _hash_splitbucket(Relation rel, ...@@ -811,6 +811,10 @@ _hash_splitbucket(Relation rel,
Size itemsz; Size itemsz;
Bucket bucket; Bucket bucket;
/* skip dead tuples */
if (ItemIdIsDead(PageGetItemId(opage, ooffnum)))
continue;
/* /*
* Fetch the item's hash key (conveniently stored in the item) and * Fetch the item's hash key (conveniently stored in the item) and
* determine which bucket it now belongs in. * determine which bucket it now belongs in.
......
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