CTE Materialization: Why the Same WITH Clause Is a Fence in PostgreSQL and a Hint in MySQL
A report query ran in 26 seconds on PostgreSQL 11 and 480 milliseconds on MySQL 8 with identical SQL, then got slow again on PostgreSQL 12 for a new reason. The WITH clause means different things to each planner, and…