EF and SQL Performance
End-to-end data access tuning across EF Core and SQL Server: projection, index tuning, compiled queries, avoiding N+1, split queries, stored procedures when needed and query plan analysis.
-
An API endpoint that reads from SQL Server through EF Core is slow, and you don't yet know where the time goes. Walk me through how you tune it end to end: from Application Insights dependency timings, to the SQL EF Core generates, to the execution plan, and how you prove each change helped.
The cross-layer method for tuning EF Core and SQL Server data access: splitting request time into app, round trips and database, finding the generated SQL, reading the plan, fixing at the right layer and verifying with numbers.
Mid-Level
Theory
EF and SQL Performance
Β· π 3 follow-ups Β· π 1 real-world
-
When would you drop down from EF Core to Dapper, raw SQL or a stored procedure for performance? What criteria do you use, how do you measure whether it is worth it, and how do you keep the codebase consistent when you do?
Deciding when EF Core should give way to SqlQuery/FromSql, Dapper or stored procedures for performance: the criteria, the evidence needed, the hidden costs and how to keep mixed data access maintainable.
Senior
Architecture
EF and SQL Performance
Β· π 3 follow-ups Β· π 1 real-world
-
A sales dashboard endpoint takes about 30 seconds and sometimes times out. It aggregates three years of orders (tens of millions of order lines) in Azure SQL through EF Core. Walk me through how you would make it fast: projection and pushing work to SQL, indexes (including columnstore), plan analysis, pre-aggregation and caching, and how you would prove each step.
An end-to-end scenario for fixing a slow reporting endpoint across EF Core and Azure SQL: measuring, server-side aggregation, columnstore and covering indexes, plan analysis, read replicas, pre-aggregated tables and caching, with evidence at each step.
Senior
RealWorldScenario
EF and SQL Performance
Β· π 3 follow-ups Β· π 1 real-world
-
Code review: an order repository exposes GetAll() as IEnumerable<Order> and filters on it, loads each order's lines in a loop, relies on lazy loading for the customer, filters by Year and Month of CreatedAt, includes a blob Attachments collection and tracks everything, all with synchronous calls. What do you flag across EF Core and SQL Server, ranked by severity, and what does the rewrite look like?
A code review of a typical slow EF Core repository: IEnumerable client-side filtering, N+1 and lazy loading, non-SARGable date predicates, blob over-fetching, unnecessary tracking, missing indexes and sync I/O, ranked by severity with a measured rewrite.
Senior
CodeReview
EF and SQL Performance
Β· π 3 follow-ups Β· π 1 real-world
-
As the technical lead for several .NET teams, how would you set performance budgets and stop performance regressions reaching production? Explain how you choose the budgets, what you test in CI (benchmarks, query counts, load tests), what you watch after release, and how you deal with noisy results and teams pushing back.
Designing a team-wide performance budget and regression system: SLO-derived budgets, BenchmarkDotNet and SQL query-count checks in CI, scheduled load tests with pass/fail thresholds, production p95 and Query Store alerts, handling noise, and getting teams to own it.
Staff / Architect
Architecture
EF and SQL Performance
Β· π 3 follow-ups Β· π 1 real-world