Re: Proposal to introduce a shuffle function to intarray extension
От | Mladen Gogala |
---|---|
Тема | Re: Proposal to introduce a shuffle function to intarray extension |
Дата | |
Msg-id | 1351c57e-4a5d-4554-8b15-1264ce0cb39a@gmail.com обсуждение исходный текст |
Ответ на | Re: Proposal to introduce a shuffle function to intarray extension (Martin Kalcher <martin.kalcher@aboutsource.net>) |
Список | pgsql-general |
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
В списке pgsql-general по дате отправления: