[COMMITTERS] pgsql: Cache hash index's metapage in rel->rd_amcache. - Mailing list pgsql-committers

From Robert Haas
Subject [COMMITTERS] pgsql: Cache hash index's metapage in rel->rd_amcache.
Date
Msg-id E1cb9kt-0001DY-Ax@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Cache hash index's metapage in rel->rd_amcache.

This avoids a very significant amount of buffer manager traffic and
contention when scanning hash indexes, because it's no longer
necessary to lock and pin the metapage for every scan.  We do need
some way of figuring out when the cache is too stale to use any more,
so that when we lock the primary bucket page to which the cached
metapage points us, we can tell whether a split has occurred since we
cached the metapage data.  To do that, we use the hash_prevblkno field
in the primary bucket page, which would otherwise always be set to
InvalidBuffer.

This patch contains code so that it will continue working (although
less efficiently) with hash indexes built before this change, but
perhaps we should consider bumping the hash version and ripping out
the compatibility code.  That decision can be made later, though.

Mithun Cy, reviewed by Jesper Pedersen, Amit Kapila, and by me.
Before committing, I made a number of cosmetic changes to the last
posted version of the patch, adjusted _hash_getcachedmetap to be more
careful about order of operation, and made some necessary updates to
the pageinspect documentation and regression tests.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/293e24e507838733aba4748b514536af2d39d7f2

Modified Files
--------------
contrib/pageinspect/expected/hash.out |   8 +-
doc/src/sgml/pageinspect.sgml         |   2 +-
src/backend/access/hash/README        |  68 ++++++++++-----
src/backend/access/hash/hash.c        |  59 +++++++------
src/backend/access/hash/hashinsert.c  |  83 ++++---------------
src/backend/access/hash/hashpage.c    | 151 +++++++++++++++++++++++++++++++++-
src/backend/access/hash/hashsearch.c  |  69 +++-------------
src/include/access/hash.h             |  20 ++++-
8 files changed, 279 insertions(+), 181 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: [COMMITTERS] pgsql: Correct thinko in last-minute release note item.
Next
From: Robert Haas
Date:
Subject: [COMMITTERS] pgsql: Fix compiler warning.