Re: Sort functions with specialized comparators
x4mmm@yandex-team.ru
From: "Andrey M. Borodin" <x4mmm@yandex-team.ru>
To: John Naylor <johncnaylorls@gmail.com>
Cc: David Rowley <dgrowleyml@gmail.com>, Антуан Виолин <violin.antuan@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-01-04T18:15:27Z
Lists: pgsql-hackers
Attachments
- v7-0001-Use-specialized-sort-facilities.patch (application/octet-stream) patch v7-0001
- v8-0001-Use-specialized-sort-facilities.patch (application/octet-stream) patch v8-0001
> On 4 Jan 2025, at 10:24, John Naylor <johncnaylorls@gmail.com> wrote:
>
> v6-0001:
>
> +static int
> +unique_cmp(const void *a, const void *b)
> +{
> + int32 aval = *((const int32 *) a);
> + int32 bval = *((const int32 *) b);
> +
> + return pg_cmp_s32(aval, bval);
> +}
>
> I'm not sure it makes sense to create a whole new function for this,
> when the same patch removed:
>
> -int
> -compASC(const void *a, const void *b)
> -{
> - return pg_cmp_s32(*(const int32 *) a, *(const int32 *) b);
> -}
>
> ...which in effect the exact same thing.
>
> Otherwise seems close to committable.
I thought about it, but decided to rename the routine.
Here's a version 7 with compASC().
And, just in case, if we already have ASC, why not keep DESC too instead of newly invented cmp function :) PFA v8.
Thanks!
Best regards, Andrey Borodin.
Commits
-
Specialize intarray sorting
- 53d3daa491be 18.0 landed
-
Replace insertion sort in contrib/intarray with qsort().
- 8d1f239003d0 9.5.0 cited