Re: window function induces full table scan

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: window function induces full table scan
Дата
Msg-id 17191.1388699570@sss.pgh.pa.us
обсуждение исходный текст
Ответ на window function induces full table scan  (Thomas Mayer <thomas.mayer@student.kit.edu>)
Ответы Re: window function induces full table scan  (Jeff Janes <jeff.janes@gmail.com>)
Re: window function induces full table scan  (Thomas Mayer <thomas.mayer@student.kit.edu>)
Список pgsql-performance
Thomas Mayer <thomas.mayer@student.kit.edu> writes:
> When querying a view with a WHERE condition, postgresql normally is able
> to perform an index scan which reduces time for evaluation dramatically.

> However, if a window function is evaluated in the view, postgresql is
> evaluating the window function before the WHERE condition is applied.
> This induces a full table scan.

You haven't exactly provided full details, but it looks like you are
thinking that WHERE clauses applied above a window function should
be pushed to below it.  A moment's thought about the semantics should
convince you that such an optimization would be incorrect: the window
function would see fewer input rows than it should, and therefore would
(in general) return the wrong values for the selected rows.

It's possible that in the specific case you exhibit here, pushing down
the clause wouldn't result in changes in the window function's output for
the selected rows, but the optimizer doesn't have enough knowledge about
window functions to determine that.

            regards, tom lane


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

Предыдущее
От: Thomas Mayer
Дата:
Сообщение: window function induces full table scan
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: window function induces full table scan