Re: Page Scan Mode in Hash Index
Ashutosh Sharma <ashu.coek88@gmail.com>
From: Ashutosh Sharma <ashu.coek88@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Jesper Pedersen <jesper.pedersen@redhat.com>,
Amit Kapila <amit.kapila16@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2017-09-20T15:43:42Z
Lists: pgsql-hackers
Attachments
- 0001-Rewrite-hash-index-scan-to-work-page-at-a-time_v16.patch (text/x-patch) patch v16-0001
- 0002-Remove-redundant-hash-function-_hash_step-and-do-som.patch (text/x-patch) patch 0002
- 0003-Improve-locking-startegy-during-VACUUM-in-Hash-Index_v7.patch (text/x-patch) patch v7-0003
On Wed, Sep 20, 2017 at 8:05 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Wed, Sep 20, 2017 at 5:37 AM, Ashutosh Sharma <ashu.coek88@gmail.com> wrote:
>> Thanks for all your review comments. Please find my comments in-line.
>
> + if (!BlockNumberIsValid(opaque->hasho_nextblkno))
> + {
> + if (so->currPos.buf == so->hashso_bucket_buf ||
> + so->currPos.buf == so->hashso_split_bucket_buf)
> + prev_blkno = InvalidBlockNumber;
> + else
> + prev_blkno = opaque->hasho_prevblkno;
> + }
>
> 1. Why not remove the outer "if" statement?
>
Yes, the outer if statement is not required. I just missed to remove
that in my earlier patch.
> 2. How about adding a comment, like /* If this is a primary bucket
> page, hasho_prevblkno is not a real block number. */
>
Added.
>> When _hash_readpage() doesn't find any qualifying tuples i.e. when
>> _hash_readnext() returns Invalid buffer, we just update prevPage,
>> nextPage and buf in
>> currPos (not currPage or lsn) as currPage and lsn should point to last
>> page in the hash bucket so that we can mark the killed items as dead
>> at the end of scan (with the help of _hash_kill_items). Hence, we keep
>> the currpage and lsn as it is if no more valid hash pages are found.
>
> How about adding a comment about this, by extending this comment:
>
> + * Remember next and previous block numbers for scrollable
> + * cursors to know the start position and return FALSE
> + * indicating that no more matching tuples were found.
>
> e.g. (Don't reset currPage or lsn, because we expect _hash_kill_items
> to be called for the old page after this function returns.)
>
>
Added.
Attached are the patches with above changes. Thanks.
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
Commits
-
Remove lsn from HashScanPosData.
- 22c5e73562c5 11.0 landed
-
Fix trivial mistake in README.
- 79a4a665c046 11.0 landed
-
hash: Implement page-at-a-time scan.
- 7c75ef571579 11.0 landed
-
Reduce pinning and buffer content locking for btree scans.
- 2ed5b87f96d4 9.5.0 cited