agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Optimize sort and deduplication in ginExtractEntries()
Date: Tue, 07 Apr 2026 10:27:27 +0000
Message-ID: <E1wA3eY-003NWf-1Z@gemulon.postgresql.org> (raw)

Optimize sort and deduplication in ginExtractEntries()

Remove NULLs from the array first, and use qsort to deduplicate only
the non-NULL items. This simplifies the comparison function. Also
replace qsort_arg() with a templated version so that the comparison
function can be inlined. These changes make ginExtractEntries() a
little faster especially for simple datatypes like integers.

Author: David Geier <geidav.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/6d16b6bd-a1ff-4469-aefb-a1c8274e561a@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6f5ad00ab763f9e029ec591f7f650bd09c1e933f

Modified Files
--------------
src/backend/access/gin/ginutil.c | 151 +++++++++++++++++----------------------
src/include/access/gin_private.h |   2 +-
2 files changed, 68 insertions(+), 85 deletions(-)



Message-ID: <E1wA3eY-003NWf-1Z@gemulon.postgresql.org>
Permalink:  ../E1wA3eY-003NWf-1Z@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wA3eY-003NWf-1Z@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Optimize sort and deduplication in ginExtractEntries()
  In-Reply-To: <E1wA3eY-003NWf-1Z@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox