Thread: Re: array_random
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 am not against this at all, but what is the actual use case?
--
Vik Fearing
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