Re: Should we optimize the `ORDER BY random() LIMIT x` case?
От | Andrei Lepikhov |
---|---|
Тема | Re: Should we optimize the `ORDER BY random() LIMIT x` case? |
Дата | |
Msg-id | 17dae319-a3bc-4707-b606-4847001697f0@gmail.com обсуждение исходный текст |
Ответ на | Re: Should we optimize the `ORDER BY random() LIMIT x` case? (Aleksander Alekseev <aleksander@timescale.com>) |
Ответы |
Re: Should we optimize the `ORDER BY random() LIMIT x` case?
|
Список | pgsql-hackers |
On 5/19/25 12:25, Aleksander Alekseev wrote: > ``` > -- imagine replacing inefficient array_sample(array_agg(t), 10) > -- with more efficient array_sample_reservoir(t, 10) > SELECT (unnest(agg)).* AS k FROM > ( SELECT array_sample(array_agg(t), 10) AS agg FROM ( > ... here goes the subquery ... > ) AS t > ); > ``` > > ... if only we supported such a column expansion for not registered > records. Currently such a query fails with: > > ``` > ERROR: record type has not been registered > ``` I know about this issue. Having resolved it in a limited number of local cases (like FDW push-down of row types), I still do not have a universal solution worth proposing upstream. Do you have any public implementation of the array_sample_reservoir to play with? -- regards, Andrei Lepikhov
В списке pgsql-hackers по дате отправления: