What this thread does
Do first: briefly enable LogTo(Console.WriteLine, LogLevel.Information) and compare SQL command counts and durations before applying AsSplitQuery() to the query with multiplying collection joins.
Short answer
As of November 2026, this card uses EF Core 10.0 LTS as its release baseline; EF10 requires .NET 10. Tag the suspect query with .TagWith("This is my spatial query!") so its commands can be identified in logs (diagnosis). Choose the branch matching the observed cost, then compare complete request time, command count, memory and response contents. Instead of JOINs, split queries generate an additional SQL query for each included collection navigation. Each collection adds a separate SQL query; network latency, buffering and concurrent updates can outweigh the saved duplication (single/split reference).
Choose / don't choose
- One slow command: inspect its execution plan before changing query shape; use index diagnosis and EF index mapping. Apply a suitable index through the normal migration path and compare plans; indexes add write cost.
- Command count grows per parent: replace lazy loading with eager loading or projection; splitting a fixed collection query is a different remedy from avoiding lazy loading.
- Too many rows/columns: project and bound results. No-tracking queries are useful when the results are used in a read-only scenario; scalar-only projections already avoid entity tracking (tracking). Don't remove tracking from edits that depend on it.
- Sibling collection growth: choose a split query when duplicate transfer/materialization dominates; keep a single query when latency or read consistency dominates. A serializable or snapshot transaction can mitigate inconsistent split reads, with its own performance cost (tradeoffs).
- SQL is quick: inspect runtime counters for CPU, allocation and thread-pool pressure before rewriting SQL.
Not for: Django endpoint performance; see django-speed-up-slow-page-endpoint-measure-sql-or-python.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
LogTo | Console.WriteLine, LogLevel.Information temporarily; logging itself adds overhead | EF Core current docs, November 2026 | diagnosis |
AsSplitQuery() | Append after the collection Includes, before materialization | Relational EF Core | split queries |
UseQuerySplittingBehavior() | UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); unconfigured default is single query | Relational EF Core | context default |
AsSingleQuery() | Override a split context default for this query | Relational EF Core | override |
OrderBy / ThenBy | Sort by date plus unique ID before Skip()/Take(); e.g. OrderBy(b => b.Date).ThenBy(b => b.PostId) | Required for split pagination before EF10; prudent explicit order on newer versions too | pagination, proof |
dnx dotnet-counters monitor | --process-id <PID> --counters System.Runtime for the API process | .NET SDK 10.0.100+ one-shot execution | counters |
Order of operations
1. Capture one representative request with brief command logging and query tags. Compare command timings with total request time, including result reading and serialization (diagnosis). 2. For a confirmed collection-join bottleneck, retain the existing filter and all needed Includes, and append the split marker before executing:
var blogs = await ctx.Blogs
.Include(b => b.Posts)
.Include(b => b.Contributors)
.AsSplitQuery()
.ToListAsync();
The sibling collection names illustrate the documented cross-product shape (reference). 3. When adding pagination, put fully unique ordering before row limits. The EF10 release notes say EF10 ensures that ordering is consistent across queries; Date alone is insufficient when timestamps tie. Append the entity's unique key (pagination). 4. Compare rows and child identities, command counts, full request latency and memory with the original query. Inspect behavior under concurrent writes if the response needs a consistent read. Prefer a local override before changing every query's context default.
Known failures and fixes
Diagnostic: empty child collections
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
empty child collections | wpsmaxi reports a projected split query with reference navigation and nonunique paging order on EF10 | Keep an explicit unique tie-breaker; inspect generated paging SQL. The report was closed on November 17, 2026 by merged PR #39687; no released version containing the fix is established here. | October 9, 2026 report, pagination |
Regression in query times | An upgrade can change SQL translation; this symptom does not prove a missing index or that splitting will help | Compare before/after SQL and plans before selecting the diagnosis branch | IIamaseconds, September 11, 2026, diagnosis |
Missing
- No universal speedup or isolation policy follows from collection count alone. Representative data, provider, network latency and response consistency requirements determine the choice.
- EF10's ordering improvement does not establish that every projected query shape is covered; the reported projection shape was fixed by merged PR #39687, but no released version is established here, so retain explicit unique ordering.
Checked
2026-11-19; EF10 release notes, single/split, pagination, diagnosis, efficient-querying, index, tracking and counter references, plus dated wpsmaxi and IIamaseconds reports read. No API, SQL or counter commands executed.
Started from a post by @Microsoft, packaged by the editor. Original post