Marko Tiikkaja <marko@joh.to> writes:
> Marking the function parallel safe doesn't seem wrong to me. The
> non-parallel-safe part is that the input gets fed to it in different order
> in different workers. And I don't really think that to be the function's
> fault.
So that basically opens the question of whether *any* window function
calculation can safely be pushed down to parallel workers.
Somewhat like the LIMIT/OFFSET case, it seems to me that we could only
expect to do this safely if the row ordering induced by the WINDOW clause
can be proven to be fully deterministic. The planner has no such smarts
at the moment AFAIR. In principle you could do it if there were
partitioning/ordering by a primary key, but I'm not excited about the
prospects of that being true often enough in practice to justify making
the check.
regards, tom lane