aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-11-08 10:47:52 -0500
committerRobert Haas <rhaas@postgresql.org>2016-11-08 10:52:51 -0500
commitf0e72a25b05d4c29d0102fa0b892782ff193a00e (patch)
tree196f60f07cd095f5a0f2dc4fea5c797d2ab357f8
parent650b96707672599e290c982dd63e3a896dbbaba6 (diff)
downloadpostgresql-f0e72a25b05d4c29d0102fa0b892782ff193a00e.tar.gz
postgresql-f0e72a25b05d4c29d0102fa0b892782ff193a00e.zip
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.
-rw-r--r--src/backend/access/hash/hashovfl.c4
-rw-r--r--src/backend/access/hash/hashpage.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c
index db3e268a761..df7af3ec842 100644
--- a/src/backend/access/hash/hashovfl.c
+++ b/src/backend/access/hash/hashovfl.c
@@ -656,6 +656,10 @@ _hash_squeezebucket(Relation rel,
IndexTuple itup;
Size itemsz;
+ /* skip dead tuples */
+ if (ItemIdIsDead(PageGetItemId(rpage, roffnum)))
+ continue;
+
itup = (IndexTuple) PageGetItem(rpage,
PageGetItemId(rpage, roffnum));
itemsz = IndexTupleDSize(*itup);
diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c
index 178463fcb65..a5e9d176a7c 100644
--- a/src/backend/access/hash/hashpage.c
+++ b/src/backend/access/hash/hashpage.c
@@ -811,6 +811,10 @@ _hash_splitbucket(Relation rel,
Size itemsz;
Bucket bucket;
+ /* skip dead tuples */
+ if (ItemIdIsDead(PageGetItemId(opage, ooffnum)))
+ continue;
+
/*
* Fetch the item's hash key (conveniently stored in the item) and
* determine which bucket it now belongs in.