DEV Community

Cover image for How Readyset Rewrites Your SQL: Subqueries in HAVING, ORDER BY, JOIN ON
ReadySet
ReadySet

Posted on

How Readyset Rewrites Your SQL: Subqueries in HAVING, ORDER BY, JOIN ON

Readyset's rewrite pipeline now handles subqueries in four new positions: HAVING, ORDER BY, INNER JOIN ON, and LEFT OUTER JOIN ON. Queries that previously fell back to the upstream database now compile and maintain incrementally.

BI tools, reporting queries, and hand-written SQL regularly put subqueries in these positions. All four rewrites build on the same underlying idea of moving the subquery to a position that existing decorrelation already handles.

LEFT OUTER JOIN ON required a different approach entirely, because the obvious move of placing the subquery predicate in WHERE silently drops rows the join was meant to preserve. The post works through what the correct solution looks like and why the mechanics of the dataflow model make it necessary.

Read the full article here.

Top comments (0)