From ccd7cdfad9f2d14e4aa797ed4b48013fba96b23d Mon Sep 17 00:00:00 2001 From: ashu Date: Wed, 8 Feb 2017 11:02:13 +0530 Subject: [PATCH] Improve locking startegy during VACUUM in Hash Index. As the new hash index scan work a page at a time, vacuum can release the lock on previous page before trying to acquire lock on a next page thereby improving hash index concurrency. Patch by Ashutosh Sharma. --- src/backend/access/hash/hash.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index c1c1fec..5e1c313 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -828,19 +828,20 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf, if (!BlockNumberIsValid(blkno)) break; - next_buf = _hash_getbuf_with_strategy(rel, blkno, HASH_WRITE, - LH_OVERFLOW_PAGE, - bstrategy); - /* - * release the lock on previous page after acquiring the lock on next - * page + * As the new hash index scan work in page at a time mode, + * vacuum can release the lock on previous page before + * acquiring lock on the next page. */ if (retain_pin) LockBuffer(buf, BUFFER_LOCK_UNLOCK); else _hash_relbuf(rel, buf); + next_buf = _hash_getbuf_with_strategy(rel, blkno, HASH_WRITE, + LH_OVERFLOW_PAGE, + bstrategy); + buf = next_buf; } -- 1.8.3.1