Hello,
I am running into performance issues with large CTE "WITH" queries (just for selecting, not updating).  I was surprised to find that the queries run much faster if I convert the CTEs to subqueries. From googling, I see that this is due to CTE acting as an optimization fence in PG. Unfortunately due to the application I'm dealing with, converting all CTE queries to subquery model is not feasible. Plus, the readability of CTE is a big bonus.

I see there was some discussion last year about removing the CTE optimization fence (e.g. http://www.postgresql-archive.org/CTE-inlining-td5958992.html) but can't find anything more recent. Does anyone know if this is still under consideration? For what it's worth, I would love some way to make CTEs inlined/optimized.

Thank you very much to the developers for a truly amazing database system.

Thanks
Guy


Reply via email to