On Mon, Sep 23, 2019 at 9:20 PM Finnerty, Jim <jfinn...@amazon.com> wrote: > If the function was moved to the FROM clause where it would be executed as a > lateral cross join instead of a target list expression, how would this affect > the cost-based positioning of the Gather?
I think you'd end up turning what is now a Seq Scan into a Nested Loop with a Seq Scan on one side. I think the computation of the target list would be done by the Function Scan or Result node on the other side of the Nested Loop, and couldn't move anywhere else. The planner would consider putting the Gather either on top of the Nested Loop or on top of the Seq Scan, and the former would probably win. So I think this would give the desired behavior, but I haven't thought about it very hard. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company