Skip to content
Preptima
mediumConceptScenarioMidSeniorStaff

This EF Core query is slow. How do you work out why, and what does change tracking have to do with it?

EF Core query performance starts with the generated SQL, then checks N+1 queries, cartesian Include joins, over-fetching and change tracking. Use projections and AsNoTracking when the result is read-only.

5 min readUpdated 2026-08-15

Answer

Short answer

Inspect the SQL before changing LINQ. Fix missing indexes or bad predicates in the database, remove lazy-loading N+1s, project only needed columns, and turn off tracking for read-only results.

Was this answer helpful?

Likely follow-ups

  • When does AsNoTracking give you the wrong results, and what does AsNoTrackingWithIdentityResolution change?
  • Why can an Include of two collection navigations make a query slower than two separate round trips, and what does AsSplitQuery do about it?
  • If tracking is the bottleneck in a bulk import, what do you change other than the query?
  • How would you confirm the fix is real rather than a warm-cache illusion?

Related questions

Further reading