From: Mladen Gogala <gogala.mladen@gmail.com>
To: Martin Kalcher <martin.kalcher@aboutsource.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Proposal to introduce a shuffle function to intarray extension
Date: Sat, 16 Jul 2022 17:30:08 -0400
Message-ID: <1351c57e-4a5d-4554-8b15-1264ce0cb39a@gmail.com> (raw)
In-Reply-To: <7933c4a5-0e72-889e-1be9-e3574ffe333b@aboutsource.net>
References: <9d160a44-7675-51e8-60cf-6d64b76db831@aboutsource.net>
<b1715621-8d89-cddf-e488-bc140b6028c7@gmail.com>
<7933c4a5-0e72-889e-1be9-e3574ffe333b@aboutsource.net>
On 7/16/22 16:21, Martin Kalcher wrote:
> Hey Mladen,
>
> thank you for your advice. Unfortunately the performance of shuffling
> with NumPy is about the same as with SQL.
>
> create function numpy_shuffle(arr int[])
> returns int[]
> as $$
> import numpy
> numpy.random.shuffle(arr)
> return arr
> $$ language 'plpython3u';
>
> select arr[1:3]::text || ' ... ' || arr[3999998:4000000]::text
> from (
> select numpy_shuffle(arr) arr from numbers
> ) shuffled;
>
> -------------------------------------------------------
> {674026,3306457,1727170} ... {343875,3825484,1235246}
>
> Time: 2315.431 ms (00:02.315)
>
> Am i doing something wrong?
>
> Martin
Hi Martin,
No, you're doing everything right. I have no solution for you. You may
need to do some C programming or throw a stronger hardware at the
problem. The performance of your processors may be the problem. Good luck!
--
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: gogala.mladen@gmail.com, martin.kalcher@aboutsource.net
Subject: Re: Proposal to introduce a shuffle function to intarray extension
In-Reply-To: <1351c57e-4a5d-4554-8b15-1264ce0cb39a@gmail.com>
References: <9d160a44-7675-51e8-60cf-6d64b76db831@aboutsource.net> <b1715621-8d89-cddf-e488-bc140b6028c7@gmail.com> <7933c4a5-0e72-889e-1be9-e3574ffe333b@aboutsource.net> <1351c57e-4a5d-4554-8b15-1264ce0cb39a@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox