pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <kgrittn@postgresql.org>
To: pgsql-committers@postgresql.org
Subject: pgsql: Reduce pinning and buffer content locking for btree scans.
Date: Wed, 25 Mar 2015 19:50:39 +0000
Message-ID: <E1YarK3-0005qN-HT@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Reduce pinning and buffer content locking for btree scans.

Even though the main benefit of the Lehman and Yao algorithm for
btrees is that no locks need be held between page reads in an
index search, we were holding a buffer pin on each leaf page after
it was read until we were ready to read the next one.  The reason
was so that we could treat this as a weak lock to create an
"interlock" with vacuum's deletion of heap line pointers, even
though our README file pointed out that this was not necessary for
a scan using an MVCC snapshot.

The main goal of this patch is to reduce the blocking of vacuum
processes by in-progress btree index scans (including a cursor
which is idle), but the code rearrangement also allows for one
less buffer content lock to be taken when a forward scan steps from
one page to the next, which results in a small but consistent
performance improvement in many workloads.

This patch leaves behavior unchanged for some cases, which can be
addressed separately so that each case can be evaluated on its own
merits.  These unchanged cases are when a scan uses a non-MVCC
snapshot, an index-only scan, and a scan of a btree index for which
modifications are not WAL-logged.  If later patches allow  all of
these cases to drop the buffer pin after reading a leaf page, then
the btree vacuum process can be simplified; it will no longer need
the "super-exclusive" lock to delete tuples from a page.

Reviewed by Heikki Linnakangas and Kyotaro Horiguchi

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/2ed5b87f96d473962ec5230fd820abfeaccb2069

Modified Files
--------------
src/backend/access/nbtree/README      |   83 +++++++++++-------
src/backend/access/nbtree/nbtinsert.c |    4 +-
src/backend/access/nbtree/nbtree.c    |   86 +++++++++++-------
src/backend/access/nbtree/nbtsearch.c |  156 +++++++++++++++++++++++++--------
src/backend/access/nbtree/nbtutils.c  |   88 +++++++++++++------
src/backend/access/nbtree/nbtxlog.c   |    3 +-
src/backend/storage/buffer/README     |    4 +-
src/include/access/nbtree.h           |   36 +++++++-
8 files changed, 327 insertions(+), 133 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1YarK3-0005qN-HT@gemulon.postgresql.org>
Permalink:  ../E1YarK3-0005qN-HT@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1YarK3-0005qN-HT@gemulon.postgresql.org

 · 

reply

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: kgrittn@postgresql.org
  Subject: Re: pgsql: Reduce pinning and buffer content locking for btree scans.
  In-Reply-To: <E1YarK3-0005qN-HT@gemulon.postgresql.org>
  References: <E1YarK3-0005qN-HT@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