From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Speedup hash index builds by skipping needless binary searches
Date: Thu, 24 Nov 2022 04:22:44 +0000
Message-ID: <E1oy3l5-000aFU-GX@gemulon.postgresql.org> (raw)
Speedup hash index builds by skipping needless binary searches
When building hash indexes using the spool method, tuples are added to the
index page in hashkey order. Because of this, we can safely skip
performing the binary search on the existing tuples on the page to find
the location to insert the tuple based on its hashkey value. For this
case, we can just always put the tuple at the end of the item array as the
tuples will always arrive in hashkey order.
Testing has shown that this can improve hash index build speeds by 5-15%
with a unique set of integer values.
Author: Simon Riggs
Reviewed-by: David Rowley
Tested-by: David Zhang, Tomas Vondra
Discussion: https://postgr.es/m/CANbhV-GBc5JoG0AneUGPZZW3o4OK5LjBGeKe_icpC3R1McrZWQ@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/d09dbeb9bde6b9faabd30e887eff4493331d6424
Modified Files
--------------
src/backend/access/hash/hash.c | 4 ++--
src/backend/access/hash/hashinsert.c | 41 +++++++++++++++++++++++++++++-------
src/backend/access/hash/hashsort.c | 3 ++-
src/include/access/hash.h | 6 ++++--
4 files changed, 41 insertions(+), 13 deletions(-)
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: drowley@postgresql.org
Subject: Re: pgsql: Speedup hash index builds by skipping needless binary searches
In-Reply-To: <E1oy3l5-000aFU-GX@gemulon.postgresql.org>
References: <E1oy3l5-000aFU-GX@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