Re: Some question about lazy subquery/procedures execution in SELECT ... ORDER BY... LIMIT N queries

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: Some question about lazy subquery/procedures execution in SELECT ... ORDER BY... LIMIT N queries
Дата
Msg-id
24774.1322154302@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
Some question about lazy subquery/procedures execution in SELECT ... ORDER BY... LIMIT N queries Maxim Boguk <maxim.boguk@gmail.com>
Re: Some question about lazy subquery/procedures execution in SELECT ... ORDER BY... LIMIT N queries Tom Lane <tgl@sss.pgh.pa.us>
Re: Some question about lazy subquery/procedures execution in SELECT ... ORDER BY... LIMIT N queries Maxim Boguk <maxim.boguk@gmail.com>
Re: Some question about lazy subquery/procedures execution in SELECT ... ORDER BY... LIMIT N queries Craig Ringer <ringerc@ringerc.id.au>
Re: Some question about lazy subquery/procedures execution in SELECT ... ORDER BY... LIMIT N queries Maxim Boguk <maxim.boguk@gmail.com>
Maxim Boguk  writes:
> Is here any reason why Postgresql calculates subqueries/storable procedures
> in select list before applying ORDER BY / LIMIT?

Well, that's the definition of ORDER BY --- it happens after computing
the select list, according to the SQL standard.  We try to optimize this
in some cases but you can't really complain when we don't.  Consider
putting the expensive function outside the ORDER BY/LIMIT, ie

select ..., expensive_fn() from (select ... order by ... limit ...) ss;

			regards, tom lane
В списке pgsql-performance по дате отправления
От: Maxim Boguk
Дата:
От: MirrorX
Дата:
FAQ