pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Reduce path length for locking leaf B-tree pages during insertio
Date: Fri, 27 Jul 2018 21:37:59 +0000
Message-ID: <E1fjAQx-0002N6-Bc@gemulon.postgresql.org> (raw)

Reduce path length for locking leaf B-tree pages during insertion

In our B-tree implementation appropriate leaf page for new tuple
insertion is acquired using _bt_search() function.  This function always
returns leaf page locked in shared mode.  In order to obtain exclusive
lock, caller have to relock the page.

This commit makes _bt_search() function lock leaf page immediately in
exclusive mode when needed.  That removes unnecessary relock and, in
turn reduces lock contention for B-tree leaf pages.  Our experiments
on multi-core systems showed acceleration up to 4.5 times in corner
case.

Discussion: https://postgr.es/m/CAPpHfduAMDFMNYTCN7VMBsFg_hsf0GqiqXnt%2BbSeaJworwFoig%40mail.gmail.com
Author: Alexander Korotkov
Reviewed-by: Yoshikazu Imai, Simon Riggs, Peter Geoghegan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d2086b08b023c0749a53d617ff3fe0f052646254

Modified Files
--------------
src/backend/access/nbtree/nbtinsert.c | 19 ++++-----------
src/backend/access/nbtree/nbtsearch.c | 44 +++++++++++++++++++++++++++++------
2 files changed, 41 insertions(+), 22 deletions(-)



Message-ID: <E1fjAQx-0002N6-Bc@gemulon.postgresql.org>
Permalink:  ../E1fjAQx-0002N6-Bc@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fjAQx-0002N6-Bc@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: akorotkov@postgresql.org
  Subject: Re: pgsql: Reduce path length for locking leaf B-tree pages during insertio
  In-Reply-To: <E1fjAQx-0002N6-Bc@gemulon.postgresql.org>
  References: <E1fjAQx-0002N6-Bc@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