Re: Proposal to introduce a shuffle function to intarray extension

From: Martin Kalcher <martin(dot)kalcher(at)aboutsource(dot)net>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal to introduce a shuffle function to intarray extension
Date: 2022-07-17 16:15:51
Message-ID: 5ef15c6f-e108-53af-3d82-587fac394f1a@aboutsource.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Am 17.07.22 um 08:00 schrieb Thomas Munro:
>> Actually ... is there a reason to bother with an intarray version
>> at all, rather than going straight for an in-core anyarray function?
>> It's not obvious to me that an int4-only version would have
>> major performance advantages.
>
> Yeah, that seems like a good direction. If there is a performance
> advantage to specialising, then perhaps we only have to specialise on
> size, not type. Perhaps there could be a general function that
> internally looks out for typbyval && typlen == 4, and dispatches to a
> specialised 4-byte, and likewise for 8, if it can, and that'd already
> be enough to cover int, bigint, float etc, without needing
> specialisations for each type.

I played around with the idea of an anyarray shuffle(). The hard part
was to deal with arrays with variable length elements, as they can not
be swapped easily in place. I solved it by creating an intermediate
array of references to the elements. I'll attach a patch with the proof
of concept. Unfortunatly it is already about 5 times slower than the
specialised version and i am not sure if it is worth going down that road.

Martin

Attachment Content-Type Size
0001-introduce-array_shuffle.patch text/x-patch 3.4 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gogala, Mladen 2022-07-17 18:58:12 Re: Oracle to Postgress Migration
Previous Message Martin Kalcher 2022-07-17 09:54:22 Re: Proposal to introduce a shuffle function to intarray extension

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikita Malakhov 2022-07-17 18:15:03 Re: [PATCH] Compression dictionaries for JSONB
Previous Message Yura Sokolov 2022-07-17 16:10:12 Re: Reducing the chunk header sizes on all memory context types