When can you push a filter into a subquery?
The outer query reads rows from a subquery in FROM, then uses WHERE to filter them. Moving that filter into the subquery might seem like a good way to reduce the amount of data processed later. But when does this preserve the result, and when does it change it? Compare a simple SELECT, aggregation with GROUP BY, and a subquery with ORDER BY ... LIMIT. How can you use the execution plan to tell whether the optimizer pushed the filter down?
ExplainSubqueries, CTEs, EXISTS / IN, UNIONSeniorAnalystData EngineerBackendQA