Re: Handle LIMIT/OFFSET before select clause (was: Feature request: optimizer improvement)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Handle LIMIT/OFFSET before select clause (was: Feature request: optimizer improvement)
Дата
Msg-id 9466.1383404767@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Handle LIMIT/OFFSET before select clause (was: Feature request: optimizer improvement)  (Atri Sharma <atri.jiit@gmail.com>)
Ответы Re: Handle LIMIT/OFFSET before select clause (was: Feature request: optimizer improvement)  (Joe Love <joe@primoweb.com>)
Список pgsql-hackers
Atri Sharma <atri.jiit@gmail.com> writes:
> I understand the reasons for executing SELECT before the sort. But,
> couldnt we get the planner to see the LIMIT part and push the sort
> node above the select node for this specific case?

[ Shrug... ]  I don't see the point.  If the OP actually cares about the
speed of this query, he's going to want to avoid the sort step too,
which is what makes the index a good idea.

More generally, this is not a transformation we could apply
unconditionally --- at the very least it'd need to be avoided when
volatile functions are involved, and I don't think it's invariably
a win from a cost standpoint even if there aren't semantic blockers.
But right now the planner has no real ability to reason about placement
of SELECT-list evaluation: it's done in a fixed spot in any particular
plan structure.  I don't think it's practical to add such considerations
to the rat's nest that is grouping_planner and friends.  I have
ambitions to replace all that with a Path-generation-and-comparison
approach, and the Paths used for this would need to carry some
indication of which expressions would be evaluated where.  So maybe
once that's done we could think about whether this is worth doing.
I remain dubious though.
        regards, tom lane



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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Record comparison compiler warning
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Record comparison compiler warning