Re: window function induces full table scan

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: window function induces full table scan
Дата
Msg-id 9269.1388760865@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: window function induces full table scan  (Thomas Mayer <thomas.mayer@student.kit.edu>)
Ответы Re: window function induces full table scan  (Thomas Mayer <thomas.mayer@student.kit.edu>)
Список pgsql-performance
Thomas Mayer <thomas.mayer@student.kit.edu> writes:
> To implement the optimization, subquery_is_pushdown_safe() needs to
> return true if pushing down the quals to a subquery which has window
> functions is in fact safe ("quals that only reference subquery
> outputs that are listed in the PARTITION clauses of all window functions
> in the subquery").

I'd just remove that check.

> Plus, there is a function qual_is_pushdown_safe(...) which contains an
> assertion, which might possibly become obsolete:

No, that should stay.  There are no window functions in the upper query's
WHERE, there will be none pushed into the lower's WHERE, and that's as it
must be.

> Tom, do you think that these two changes could be sufficient?

Certainly not.  What you'd need to do is include the
is-it-listed-in-all-PARTITION-clauses consideration in the code that marks
"unsafe" subquery output columns.  And update all the relevant comments.
And maybe add a couple of regression test cases.

Offhand I think the details of testing whether a given output column
appears in a given partition clause are identical to testing whether
it appears in the distinctClause.  So you'd just be mechanizing running
through the windowClause list to verify whether this holds for all
the WINDOW clauses.

Note that if you just look at the windowClause list, then you might
be filtering by named window definitions that appeared in the WINDOW
clause but were never actually referenced by any window function.
I don't have a problem with blowing off the optimization in such cases.
I don't think it's appropriate to expend the cycles that would be needed
to discover whether they're all referenced at this point.  (If anyone ever
complains, it'd be much cheaper to modify the parser to get rid of
unreferenced window definitions.)

            regards, tom lane


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

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