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

From Mladen Gogala
Subject Re: Proposal to introduce a shuffle function to intarray extension
Date
Msg-id 1351c57e-4a5d-4554-8b15-1264ce0cb39a@gmail.com
Whole thread Raw
In response to Re: Proposal to introduce a shuffle function to intarray extension  (Martin Kalcher <martin.kalcher@aboutsource.net>)
List 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 by date:

Previous
From: Martin Kalcher
Date:
Subject: Re: Proposal to introduce a shuffle function to intarray extension
Next
From: "Gogala, Mladen"
Date:
Subject: Re: Oracle to Postgress Migration