Re: some aspects of our qsort might not be ideal

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: some aspects of our qsort might not be ideal
Дата
Msg-id CAH2-Wz==W5vvXkUcRsM7Uo3tGOTBN_wqd1wbx3ivskUsVZJ2HQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: some aspects of our qsort might not be ideal  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
Ответы Re: some aspects of our qsort might not be ideal  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
Список pgsql-hackers
On Thu, Jun 23, 2022 at 7:51 AM Matthias van de Meent
<boekewurm+postgres@gmail.com> wrote:
> I think that mostly has to do with reliability / stability of ORDER BY
> in combination with LIMIT and OFFSET, even though right now we cannot
> fully guarantee such stability due to unstable results from underlying
> plan nodes.

The current qsort isn't stable. While quicksort is never stable, our
particular implementation has fairly significant optimizations that
strongly rely on not using a stable sort. In particular, the B&M
optimizations for duplicate elements.

These optimizations make things like datum tuplesorts for
'SELECT(DISTINCT mycol) ...' style queries on low cardinality columns
extremely fast. We're not really sorting so much as bucketing. This is
based on Dijkstra's Dutch national flag problem.

-- 
Peter Geoghegan



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

Предыдущее
От: Matthias van de Meent
Дата:
Сообщение: Re: some aspects of our qsort might not be ideal
Следующее
От: Matthias van de Meent
Дата:
Сообщение: Re: some aspects of our qsort might not be ideal