Re: array_random

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Vik Fearing <vik(at)postgresfriends(dot)org>
Subject: Re: array_random
Date: 2025-07-21 03:15:36
Message-ID: CACJufxHyCEnikLTamm2UaxQKfuzeE=qvyQXxSRLwA-u-QZnjJg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 11, 2025 at 3:49 PM Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> On Tue, 8 Jul 2025 at 15:26, Aleksander Alekseev
> <aleksander(at)tigerdata(dot)com> wrote:
> >
> > The proposed function seems to do two things at a time - generating
> > random values and transforming them into an array of desired
> > dimensions. Generally we try to avoid such interfaces. Can you think
> > of something like array_transform() / array_reshape() that takes an
> > arbitrary single-dimension array and modifies it?
>
> That's a good point. Arguably, creating a simple 1-D array of random
> values is trivial enough to leave to users, and there isn't sufficient
> demand to justify creating core functions for it.
>
use sql, we generally do something like:
select array_agg(random(1, 10)) from generate_series(1, 2) g;
but its performance is worse than array_random.

Does performance and other factors justify adding array_random?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-07-21 03:49:12 Re: array_random
Previous Message feichanghong 2025-07-21 01:58:09 Re: Even when the data is already ordered, MergeAppend still adds a Sort node