📎 Webclip
The Performance Issue „Cartesian Explosion“ Made Its Comeback In Entity Framework Core 3
EF Core 3.0/3.1 changed SQL generation in a way that removed implicit client-side evaluation and the N+1 query problem, but it also brought back the Cartesian Explosion problem. The article shows how one-to-many JOINs replicate rows, how extra Includes can make the result set grow quickly, and how EF adds ORDER BY clauses that can add load when the result set is large.
Reading notes#
- In EF Core 3.0/3.1, SQL generation changed significantly.
- Those changes removed implicit client-side evaluation and the N+1 query problem.
- The same changes reintroduced the Cartesian Explosion problem.
- In a one-to-many JOIN, rows from the one side are repeated for each matching row on the many side.
- With one ProductGroup and 1000 Products, the result set contains repeated ProductGroup data.
- More Includes can make the result set explode.
- EF also adds an ORDER BY on entity identifiers for internal purposes.
- That ordering adds load when the result set is very large.
- The proposed solution is query splitting, as in EF6.
- The example loads ProductGroups and Products in separate queries.
- The article says the hard part is finding queries that should be split.
- It recommends using database statistics and execution plans to decide how far to split queries.
