Re: [PATCH] Use optimized single-datum tuplesort in ExecSort

Поиск
Список
Период
Сортировка
От Ronan Dunklau
Тема Re: [PATCH] Use optimized single-datum tuplesort in ExecSort
Дата
Msg-id 3060002.hb0XKQ11pn@aivenronan
обсуждение исходный текст
Ответ на Re: [PATCH] Use optimized single-datum tuplesort in ExecSort  (James Coleman <jtc331@gmail.com>)
Ответы Re: [PATCH] Use optimized single-datum tuplesort in ExecSort
Список pgsql-hackers
Le mardi 6 juillet 2021, 17:37:53 CEST James Coleman a écrit :
> Yes and no. When incremental sort has to do a full sort there will
> always be at least 2 attributes. But in prefix sort mode (see
> prefixsort_state) only non-presorted columns are sorted (i.e., if
> given a,b already sorted by a, then only b is sorted). So the
> prefixsort_state could use this optimization.

The optimization is not when we actually sort on a single key, but when we get
a single attribute in / out of the tuplesort.  Since sorting always add
resjunk entries for the keys being sorted on, I don't think we can ever end up
in a situation where the optimization would kick in, since the entries for the
already-performed-sort keys will need to be present in the output.

Maybe if instead of adding resjunk entries to the whole query's targetlist,
sort and incrementalsort nodes were able to do a projection from the input
(needed tle + resjunk sorting tle) to a tuple containing only the needed tle
on output before actually sorting it, it would be possible, but that would be
quite a big design change.

In the meantime I fixed some formatting issues, please find attached a new
patch.


--
Ronan Dunklau
Вложения

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

Предыдущее
От: Julien Rouhaud
Дата:
Сообщение: Re: Hook for extensible parsing.
Следующее
От: Boris Kolpackov
Дата:
Сообщение: Re: Pipeline mode and PQpipelineSync()