Re: array_random - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: array_random
Date
Msg-id CAEZATCUn+fYYROQROtaSvA4v0YnchzjaptSCw+TfukgeSR3_HQ@mail.gmail.com
Whole thread Raw
In response to Re: array_random  (Vik Fearing <vik@postgresfriends.org>)
List pgsql-hackers
On Sat, 5 Jul 2025 at 08:32, Vik Fearing <vik@postgresfriends.org> wrote:
>
> On 30/06/2025 17:04, jian he wrote:
>
> reasons for adding array_random is:
> 1. This is better than array_fill. This can fill random and constant
> values (random, min and max the same).
> 2.  Building a multi-dimensional PL/pgSQL function equivalent to
> array_random is not efficient and is also not easier.

I took a quick look at this and there are a number of things that I
don't like about the implementation. However, ...

> I am not against this at all, but what is the actual use case?

I think that's a reasonable question to ask.

The original use case [1] was to produce arrays of random numbers for
testing gin indexes.

[1] https://www.postgresql.org/message-id/87plssezpc.fsf%40163.com

However, this is adding quite a lot of C code for something that's
actually pretty easy to do as a user-defined function in SQL. Maybe
that's OK, if it's something that there's a lot of demand for, but
it's worth asking that question.

Regards,
Dean



pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Re: Consider explicit incremental sort for Append and MergeAppend
Next
From: Evgeny Voropaev
Date:
Subject: Re: Add 64-bit XIDs into PostgreSQL 15