Re: optimization with limit and order by in a view

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: optimization with limit and order by in a view
Дата
Msg-id 19127.1089755750@sss.pgh.pa.us
обсуждение исходный текст
Ответ на optimization with limit and order by in a view  (elein <elein@varlena.com>)
Ответы Re: optimization with limit and order by in a view
Список pgsql-general
elein <elein@varlena.com> writes:
> Brain dead java beans want order by clauses in views
> that they use.

That's *quite* brain dead, considering that standard SQL doesn't allow
ORDER BY in view definitions at all.  Sure you can't fix it on the
client side?

> What I found was that if I moved the order by outside
> of the view definition, the query went from 5000-7000ms
> down to 70-1.5ms.

Yeah.  The planner can't flatten a subquery that contains ORDER BY into
the parent query, because there'd be no place to put the ORDER BY.  So
when you write it that way, the subquery is planned independently and
it doesn't realize that it should use a fast-start plan instead of a
minimum-total-time plan.

I can think of various possible kluges to get around this in simple
cases, but nothing I like much...

            regards, tom lane

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

Предыдущее
От: elein
Дата:
Сообщение: optimization with limit and order by in a view
Следующее
От: Thomas F.O'Connell
Дата:
Сообщение: Indexes and Tables: Growth and Treatment (Modified by Thomas F. O'Connell)