Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> writes:
> Hello, this seems to be a matter of subquery pushdown, query
> transform involving subqueries or how to deal with views in
> planner, rather than a bug.
In general, pushing a WHERE clause down through a window function call
*would* be a bug. I think it should be safe in this case because the
WHERE clause matches the window functions' partition clauses, so that
applying the WHERE removes either all or none of the rows of any
particular partition. We've not gotten around to that type of refinement
in window function planning, yet. It would take some infrastructure that
doesn't exist now --- I don't recall that we have any code that tries to
make that particular kind of proof.
regards, tom lane