Re: Hash Indexes

Jesper Pedersen <jesper.pedersen@redhat.com>

From: Jesper Pedersen <jesper.pedersen@redhat.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Mithun Cy <mithun.cy@enterprisedb.com>, Robert Haas <robertmhaas@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2016-09-01T18:03:42Z
Lists: pgsql-hackers
On 08/05/2016 07:36 AM, Amit Kapila wrote:
> On Thu, Aug 4, 2016 at 8:02 PM, Mithun Cy <mithun.cy@enterprisedb.com> wrote:
>> I did some basic testing of same. In that I found one issue with cursor.
>>
>
> Thanks for the testing.  The reason for failure was that the patch
> didn't take into account the fact that for scrolling cursors, scan can
> reacquire the lock and pin on bucket buffer multiple times.   I have
> fixed it such that we release the pin on bucket buffers after we scan
> the last overflow page in bucket. Attached patch fixes the issue for
> me, let me know if you still see the issue.
>

Needs a rebase.

hashinsert.c

+	 * reuse the space.  There is no such apparent benefit from finsihing the

-> finishing

hashpage.c

+ *		retrun the buffer, else return InvalidBuffer.

-> return

+	if (blkno == P_NEW)
+		elog(ERROR, "hash AM does not use P_NEW");

Left over ?

+ * for unlocking it.

-> for unlocking them.

hashsearch.c

+	 * bucket, but not pin, then acuire the lock on new bucket and again

-> acquire

hashutil.c

+ * half.  It is mainly required to finsh the incomplete splits where we are

-> finish

Ran some tests on a CHAR() based column which showed good results. Will 
have to compare with a run with the WAL patch applied.

make check-world passes.

Best regards,
  Jesper



Commits

  1. Remove _hash_wrtbuf() in favor of calling MarkBufferDirty().

  2. Fix race introduced by 6d46f4783efe457f74816a75173eb23ed8930020.

  3. Improve hash index bucket split behavior.

  4. Reduce pinning and buffer content locking for btree scans.