Replies: 2 comments 5 replies
-
I'm hoping that this isn't too much of an issue, since it seems like the issue with speed occurs when I haven't tried benchmarking |
Beta Was this translation helpful? Give feedback.
-
My understanding is that CTE vs subquery performance has become much less significant over the past few years, and I notice those links are > 5 years old. Do we have any more up to date benchmarks? Ideally with a query that PRQL has produced or might produce. PRQL attempts to keep as much as possible within a single subquery. When it needs to, it does create a new subquery. And at the moment, it puts that subquery in a new CTE rather than a parenthesized subquery. Are there are cases where PRQL is making a subquery and didn't need to? |
Beta Was this translation helpful? Give feedback.
-
Hi,
In postgresql, expressing a query using CTEs rather than subqueries can have a significant impact on query runtime:
https://dba.stackexchange.com/questions/188093/why-is-postgres-cte-slower-than-subquery
Archived link to article mentioned: https://web.archive.org/web/20221206070823/https://www.2ndquadrant.com/en/blog/postgresql-ctes-are-optimization-fences/
For the query in the linked discussion:
I've noticed in the playground that CTEs are generated in the first example: https://prql-lang.org/playground/
Is there a way of pushing the SQL generation to avoid using CTEs to produce faster queries? Thanks
Beta Was this translation helpful? Give feedback.
All reactions