Re: Proposal to introduce a shuffle function to intarray extension - Mailing list pgsql-hackers

From Martin Kalcher
Subject Re: Proposal to introduce a shuffle function to intarray extension
Date
Msg-id 5ef15c6f-e108-53af-3d82-587fac394f1a@aboutsource.net
Whole thread Raw
In response to Re: Proposal to introduce a shuffle function to intarray extension  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: Proposal to introduce a shuffle function to intarray extension
Re: Proposal to introduce a shuffle function to intarray extension
List 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

pgsql-hackers by date:

Previous
From: Yura Sokolov
Date:
Subject: Re: Reducing the chunk header sizes on all memory context types
Next
From: Nikita Malakhov
Date:
Subject: Re: [PATCH] Compression dictionaries for JSONB