Topic
Databases & EF Core
EF Core and database engineering from query shape and indexes to concurrency, pagination, and connection management.
Practice this topic: EF Core practice →
Try Filter Before You Fetch → Free, no account needed
Latest articles
RSS feed →19 articles
No articles match. Try fewer words or a different term. Search all articles
EF Core cartesian explosion: Include, split, projection
An EF Core cartesian explosion multiplies sibling collections: one listing with 40 photos, 60 reviews and 100 bookings returned 240,000 rows.
Read article →Gaps and islands in SQL: streaks, sessions and duplicates
Gaps and islands in SQL come down to one label per run. The row number difference finds it, but without a tiebreaker one test reported 334 islands for 40.
Read article →SQL join double counting: why SUM inflates after a JOIN
SQL join double counting starts when a one-to-many join repeats rows before SUM runs: 3 timesheets and 2 expenses reported 44 hours for a true 22.
Read article →PostgreSQL JSONB query patterns: null, paths and GIN
A PostgreSQL JSONB query using ->> cannot tell a missing key from JSON null, and the planner's default guess for that filter was 98 times too low.
Read article →Recursive CTE in PostgreSQL for trees and cycles
A recursive CTE in PostgreSQL runs as a loop over a working table. Tracking paths on a graph of just 30 nodes grew its result from 30 rows to 88,572.
Read article →Database deadlocks: find the cycle and retry the transaction
Diagnose database deadlocks with a two-session example. Fix inconsistent lock ordering, keep transactions short, and retry the complete operation safely.
Read article →SQL EXISTS vs IN: get membership and NULLs right
Compare SQL EXISTS vs IN with worked examples, the NOT IN NULL trap, semi joins, and a query-plan method that tests performance without folklore.
Read article →Partial, covering, and expression indexes in PostgreSQL
Three PostgreSQL index shapes that end three recurring full scans: partial for the hot subset, INCLUDE for index-only scans, expression for lower(email).
Read article →SQL window functions: running totals, ranks, top-N
Window functions compute across related rows without collapsing them: OVER anatomy, ranking ties, the running-total frame trap, top-N per group, and LAG.
Read article →Transaction isolation levels: the anomalies each level allows
Database transaction isolation levels are a menu of anomalies you tolerate, not a safety dial. Watch write skew commit, then add the retry Serializable needs.
Read article →EF Core bulk updates with ExecuteUpdate and ExecuteDelete
An EF Core bulk update that loads 50,000 entities to change one column pays per byte and per statement. ExecuteUpdate sends one statement and skips the tracker.
Read article →Optimistic concurrency in EF Core: stop silent overwrites
Two users edit the same row and the last save silently wins. Use EF Core concurrency tokens, handle DbUpdateConcurrencyException, and test the race properly.
Read article →Connection pooling: why your app ran out of connections
Connection pooling explained from the failure end: what a connection costs, the three ways pools drain, and why the timeout blames the wrong request.
Read article →How do database indexes work? B-trees, page by page
How do database indexes work? A B-tree is a small sorted structure with huge fanout, so a lookup reads a handful of pages instead of the whole table.
Read article →Skip and Take will betray you: offset vs keyset pagination
OFFSET pagination reads every row it skips, so page 2,000 costs 2,000 pages of work. Keyset pagination seeks straight to the next page. SQL and EF Core shown.
Read article →EF Core habits that quietly wreck performance
Nine EF Core habits that pass every test and quietly tank production performance: missing AsNoTracking, whole-entity fetches, N+1, cartesian explosion, more.
Read article →Your LINQ is fast; your query plan isn't
A well-written EF Core query can still do a sequential scan: no index, or a function on a column makes it non-sargable. How to read a query plan and fix it.
Read article →IQueryable vs IEnumerable: the one return type that decides where your query runs
Returning IEnumerable, or calling ToList too early, moves filtering and paging into memory. One type change turns an indexed WHERE into loading a million rows.
Read article →The N+1 query problem in EF Core: the most expensive habit in .NET
An EF Core loop that looks innocent fires one query per row. It passes every unit test and dies in production. How N+1 happens, the SQL it generates, the fix.
Read article →