pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John Naylor <john.naylor@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Specialize intarray sorting
Date: Tue, 18 Feb 2025 04:05:26 +0000
Message-ID: <E1tkErO-007jHf-1L@gemulon.postgresql.org> (raw)

Specialize intarray sorting

There is at least one report in the field of storing millions of
integers in arrays, so it seems like a good time to specialize
intarray's qsort function. In doing so, streamline the comparators:
Previously there were three, two for each direction for sorting
and one passed to qunique_arg. To preserve the early exit in the
case of descending input, pass the direction as an argument to
the comparator. This requires giving up duplicate detection, which
previously allowed skipping the qunique_arg() call. Testing showed
no regressions this way.

In passing, get rid of nearby checks that the input has at least
two elements, since preserving them would make some macros less
readable. These are not necessary for correctness, and seem like
premature optimizations.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/098A3E67-E4A6-4086-9C66-B1EAEB1DFE1C@yandex-team.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/53d3daa491be458e543dd5bf24d40595e588e4e7

Modified Files
--------------
contrib/intarray/_int.h      | 20 ++++++--------
contrib/intarray/_int_tool.c | 62 +++++++++++++++++++-------------------------
2 files changed, 34 insertions(+), 48 deletions(-)



Message-ID: <E1tkErO-007jHf-1L@gemulon.postgresql.org>
Permalink:  ../E1tkErO-007jHf-1L@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tkErO-007jHf-1L@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: john.naylor@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Specialize intarray sorting
  In-Reply-To: <E1tkErO-007jHf-1L@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