From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@postgresql.org
Subject: pgsql: Cache hash index's metapage in rel->rd_amcache.
Date: Tue, 07 Feb 2017 17:40:39 +0000
Message-ID: <E1cb9kt-0001DY-Ax@gemulon.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: rhaas@postgresql.org
Subject: Re: pgsql: Cache hash index's metapage in rel->rd_amcache.
In-Reply-To: <E1cb9kt-0001DY-Ax@gemulon.postgresql.org>
References: <E1cb9kt-0001DY-Ax@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox