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>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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 23:07:22
Message-ID: 3c8e5531-aa1b-0d85-115c-540dc2a16b24@aboutsource.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Am 18.07.22 um 00:37 schrieb Thomas Munro:
> Seems OK for a worst case. It must still be a lot faster than doing
> it in SQL. Now I wonder what the exact requirements would be to
> dispatch to a faster version that would handle int4. I haven't
> studied this in detail but perhaps to dispatch to a fast shuffle for
> objects of size X, the requirement would be something like typlen == X
> && align_bytes <= typlen && typlen % align_bytes == 0, where
> align_bytes is typalign converted to ALIGNOF_{CHAR,SHORT,INT,DOUBLE}?
> Or in English, 'the data consists of densely packed objects of fixed
> size X, no padding'. Or perhaps you can work out the padded size and
> use that, to catch a few more types. Then you call
> array_shuffle_{2,4,8}() as appropriate, which should be as fast as
> your original int[] proposal, but work also for float, date, ...?
>
> About your experimental patch, I haven't reviewed it properly or tried
> it but I wonder if uint32 dat_offset, uint32 size (= half size
> elements) would be enough due to limitations on varlenas.

I made another experimental patch with fast tracks for typelen4 and
typelen8. alignments are not yet considered.

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2022-07-17 23:20:33 Re: Proposal to introduce a shuffle function to intarray extension
Previous Message Martin Kalcher 2022-07-17 23:05:19 Re: Proposal to introduce a shuffle function to intarray extension

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-07-17 23:20:33 Re: Proposal to introduce a shuffle function to intarray extension
Previous Message Dian M Fay 2022-07-17 23:07:15 Re: doc: Make selectivity example match wording