I've got a customer that is running a pretty expensive function as part
of a WHERE clause. With or without the function, the table the function
references is the inner-most of a series of nested loops. Without the
function things are very fast, but adding the function increases the
cost of the index scan on that table by a factor of ~80x. It also
falsely skews the row estimate further down, causing a bad shift to
materialization in another part of the query, but that's a different
problem. Wrapping the majority of the query in an OFFSET 0 with the
function call on the outside makes things fast again.
It'd be nice if function execution could be delayed to a higher level of
a query based on the cost.
Jim Nasby, Chief Data Architect, OpenSCG
Sent via pgsql-hackers mailing list (firstname.lastname@example.org)
To make changes to your subscription: