EF Core AsSplitQuery: Reducing Cartesian Explosion with Split Queries
When multiple collection Includes produce a Cartesian product, AsSplitQuery splits the fetch into separate queries keyed by primary keys, eliminating row duplication without changing your LINQ syntax.
13 Jun 2026, 22:16 UTC

You’ve written a LINQ query in Entity Framework Core that fetches a root entity with two collection navigations, only to find the result set inflated far beyond expectations. When two or more Include clauses target collection navigations, EF Core materializes a Cartesian product: each root row repeats once for every combination of related entities across the included collections. A blog with 2 posts and 5 tags can balloon to 10 rows for that single blog, and the effect compounds quickly.
In database terms, a Cartesian product is the mathematical result of joining two or more tables without a restrictive filter that ties each row from one table to a single row from the other. EF Core’s query materializer then groups those rows back into objects, often resulting in the same root entity appearing many times in memory. No index or query hint can reshape this behavior — only changing the query architecture does.
The Cartesian Explosion Problem
When you write context.Blogs.Include(b => b.Posts).Include(b => b.Tags).ToList(), EF Core sends a single query that joins the blogs, posts, and tags tables. The database returns rows where each blog appears once per post×tag combination. If a blog has two posts and five tags, you get ten rows for that single blog. No index can fix this shape — only changing the query does.
AsSplitQuery() to the Rescue
Since EF Core 5, AsSplitQuery() tells the provider to fetch the root entities once, then load each included collection in a separate query filtered by the root’s primary key. The navigations are fixed up in memory, so duplicated data never crosses the wire. This single method call can transform a bloated result set into a lean set of statements.
var blogs = await context.Blogs.Include(b => b.Posts).Include(b => b.Tags).AsSplitQuery().ToListAsync();
You can inspect the generated SQL with ToQueryString() on the compiled expression, or by enabling logging via optionsBuilder.LogTo(...). You should see the root entity query followed by two collection queries, each with a WHERE blogId IN (...) clause that references the identifiers returned by the first statement.
When It Matters, Trade‑offs, and Configuration
A single Include on a collection navigation does not multiply rows, so the benefit of splitting mainly appears with two or more collection includes or when the duplication would be large. For tiny result sets — say, fetching one blog with a single post and no tags — the extra round trips may cost more than the bytes saved.
Configuring the behavior globally is also possible. Setting optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery) changes the default for the entire context, while AsSingleQuery() can opt an individual query back out. This is useful when an endpoint needs strict paging or a consistent snapshot across the fetched graph.
Trade‑offs and Limitations
The primary trade‑off is round‑trip count. Instead of one network hop, you pay for one extra hop per included collection. On high‑latency connections or very high QPS paths, this can increase overall request time.
Another limitation: split queries do not guarantee a consistent snapshot across the individual statements. If rows change between the root fetch and the collection fetches, the fixed‑up graph may reflect stale data. Wrapping the operation in a transaction can mitigate this, but only if the transaction isolation level permits reading the same snapshot across multiple statements.
Version‑specific notes apply as well. Skip/Take combined with split queries has had restrictions in past EF Core releases, so confirm the behavior for your exact version. Additionally, AsNoTracking still applies, but identity resolution and fix‑up semantics differ slightly — verify expectations if you rely on tracked instances.
Verification and Practical Checks
- Inspect the query text — Run both the split and non‑split variants and call
ToQueryString()on the compiled expression. Compare the number of statements and theWHEREclauses. - Enable logging — Add
optionsBuilder.LogTo(...)and review the generated SQL plus any EF Core performance warnings. Look for the cartesian-explosion log entry if your EF Core version emits it. - Benchmark realistic data — Use a small benchmark or manual timing that measures round trips, bytes transferred, and end‑to‑end latency for both shapes against your actual data volume.
- Check your EF Core version — The Split queries documentation for your version notes paging, transaction, and default-behavior caveats.
AsSplitQuery() is a targeted fix for a specific EF Core behavior: Cartesian explosion from multiple collection Include clauses. It’s not a silver bullet for every performance concern, but when you’re facing row duplication and want to keep your LINQ syntax intact, it’s a practical tool. Pair it with logging and a quick benchmark for your data profile, and you can decide whether the trade‑off of extra round trips is worth the reduction in transferred bytes.