Re: [PATCH] Introduce array_shuffle() and array_sample()

Поиск
Список
Период
Сортировка
От Martin Kalcher
Тема Re: [PATCH] Introduce array_shuffle() and array_sample()
Дата
Msg-id 8617d454-0cd6-93bb-b18d-23a97ba40cb4@aboutsource.net
обсуждение исходный текст
Ответ на Re: [PATCH] Introduce array_shuffle() and array_sample()  (Martin Kalcher <martin.kalcher@aboutsource.net>)
Ответы Re: [PATCH] Introduce array_shuffle() and array_sample()  (Aleksander Alekseev <aleksander@timescale.com>)
Список pgsql-hackers
Am 19.07.22 um 00:52 schrieb Martin Kalcher:
> 
> On the contrary! I am pretty sure there are people out there wanting 
> sampling-without-shuffling. I will think about that.

I gave it some thought. Even though there might be use cases, where a 
stable order is desired, i would consider them edge cases, not worth the 
additional complexity. I personally would not expect array_sample() to 
return elements in any specific order. I looked up some sample() 
implementations. None of them makes guarantees about the order of the 
resulting array or explicitly states that the resulting array is in 
random or selection order.

- Python random.sample [0]
- Ruby Array#sample [1]
- Rust rand::seq::SliceRandom::choose_multiple [2]
- Julia StatsBase.sample [3] stable order needs explicit request

[0] https://docs.python.org/3/library/random.html#random.sample
[1] https://ruby-doc.org/core-3.0.0/Array.html#method-i-sample
[2] 
https://docs.rs/rand/0.6.5/rand/seq/trait.SliceRandom.html#tymethod.choose_multiple
[3] https://juliastats.org/StatsBase.jl/stable/sampling/#StatsBase.sample



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "osumi.takamichi@fujitsu.com"
Дата:
Сообщение: RE: [BUG] Logical replication failure "ERROR: could not map filenode "base/13237/442428" to relation OID" with catalog modifying txns
Следующее
От: John Naylor
Дата:
Сообщение: Re: NAMEDATALEN increase because of non-latin languages