pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add bound check before bsearch() for performance
Date: Wed, 10 Mar 2021 14:52:31 +0000
Message-ID: <E1lK0CN-0001GJ-7o@gemulon.postgresql.org> (raw)

Add bound check before bsearch() for performance

In the current lazy vacuum implementation, some index AMs such as
btree indexes call lazy_tid_reaped() for each index tuple during
ambulkdelete to check if the index tuple points to the (collected)
garbage tuple.  In that function, we simply call bsearch(), but we
should be able to know the result without bsearch() if the index tuple
points to the heap tuple that is out of range of the collected garbage
tuples.  Therefore, add a simple bound check before resorting to
bsearch().  Testing has shown that this can give significant
performance benefits.

Author: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Discussion: https://www.postgresql.org/message-id/flat/CA+fd4k76j8jKzJzcx8UqEugvayaMSnQz0iLUt_XgBp-_-bd22A@mail....

Branch
------
master

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

Modified Files
--------------
src/backend/access/heap/vacuumlazy.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)



Message-ID: <E1lK0CN-0001GJ-7o@gemulon.postgresql.org>
Permalink:  ../E1lK0CN-0001GJ-7o@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lK0CN-0001GJ-7o@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: peter@eisentraut.org
  Subject: Re: pgsql: Add bound check before bsearch() for performance
  In-Reply-To: <E1lK0CN-0001GJ-7o@gemulon.postgresql.org>
  References: <E1lK0CN-0001GJ-7o@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