Re: Sort functions with specialized comparators - Mailing list pgsql-hackers

From John Naylor
Subject Re: Sort functions with specialized comparators
Date
Msg-id CANWCAZYjEndXeqyT9Wvnbkx1f0ayv4JJ-DHd0u_0QOYVNiYiJA@mail.gmail.com
Whole thread Raw
In response to Sort functions with specialized comparators  ("Andrey M. Borodin" <x4mmm@yandex-team.ru>)
List pgsql-hackers
On Wed, Dec 4, 2024 at 2:47 PM Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:
> sort_int32_cmp Time: 543.690 ms
> sort_int32_cmp_2 Time: 609.019 ms
> sort_int32_cmp_4 Time: 612.219 ms
>
> So, I'd stick with sort_int32_cmp. But, perhaps, on Intel we might have different results.

I tried on an older Intel chip and got similar results, so we'll go
with your original comparator:

master: latency average = 1867.878 ms
cmp1: latency average   = 1189.225 ms
cmp2: latency average   = 1341.153 ms
cmp3: latency average   = 1270.053 ms

I believe src/port/qsort.c was meant to be just for the standard sort
interface as found in a C library. We do have one globally visible
special sort here:
src/backend/utils/sort/qsort_interruptible.c
...so that directory seems a better fit. The declaration is in
src/include/port.h, though. Note: that one doesn't have a global
wrapper around a static function -- it's declared global since
ST_SCOPE is not defined.

And one more bikeshedding bit that might get noticed: tuplesorts
express their boolean as "reversed". We don't necessarily need to
follow that, but consistency is good for readability.

--
John Naylor
Amazon Web Services



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Disallow UPDATE/DELETE on table with unpublished generated column as REPLICA IDENTITY
Next
From: John Naylor
Date:
Subject: Re: CSN snapshots in hot standby