Re: [PATCH] Introduce array_shuffle() and array_sample()
Martin Kalcher <martin.kalcher@aboutsource.net>
From: Martin Kalcher <martin.kalcher@aboutsource.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>,
John Naylor <john.naylor@enterprisedb.com>,
Thomas Munro <thomas.munro@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-07-18T22:52:47Z
Lists: pgsql-hackers, pgsql-general
Am 19.07.22 um 00:18 schrieb Tom Lane: > > Independently of the dimensionality question --- I'd imagined that > array_sample would select a random subset of the array elements > but keep their order intact. If you want the behavior shown > above, you can do array_shuffle(array_sample(...)). But if we > randomize it, and that's not what the user wanted, she has no > recourse. > > Now, if you're convinced that the set of people wanting > sampling-without-shuffling is the empty set, then making everybody > else call two functions is a loser. But I'm not convinced. > At the least, I'd like to see the argument made why nobody > would want that. > On the contrary! I am pretty sure there are people out there wanting sampling-without-shuffling. I will think about that.
Commits
-
Add array_sample() and array_shuffle() functions.
- 888f2ea0a81f 16.0 landed
-
Use a separate random seed for SQL random()/setseed() functions.
- 6645ad6bdd81 12.0 cited