Blog
Posts and series that take software and IT from the basics to advanced topics: from programming languages and databases to architecture and AI.
Plan Cache, Parameterization and Parameter Sniffing: Symptoms, Diagnosis and Fixes
Parameter sniffing is a cached plan compiled for the first parameter value that does not fit other values on skewed data: the same procedure did 7,709 logical reads for customer 1 in one order and 612,850 in the other. Ad hoc/prepared plans, simple and forced parameterization, the price of RECOMPILE and OPTIMIZE FOR, 2022's PSP optimization, 2025's OPPO, and plan cache bloat from ORM parameter lengths.
Reading Execution Plans 2: Memory Grants, Spills, Parallelism and Implicit Conversion Warnings
Plan warnings show the price of an estimate: a small estimate leaves the memory grant short and spills to tempdb, a low cost threshold spreads small queries over 10 threads, and an nvarchar parameter on a varchar column turns a 3-page lookup into 3,117 pages. Memory grant feedback, exchange operators, CX waits, DOP feedback on by default in 2025, implicit conversion with EF Core and Dapper, batch mode and adaptive joins.
Reading Execution Plans 1: Estimated vs Actual Plans, Operators and Join Algorithms
An execution plan is read right to left, inside out; the first thing to check is not cost percentage but estimated versus actual rows and how many times each operator ran. Where cost percentage misleads in the actual plan of an EF Core Include query, seek/scan/lookup, the measured cost of nested loops, merge and hash joins on the same query, stream and hash aggregates, and going from 2,549 to 689 logical reads with two indexes.
Statistics and Cardinality Estimation: Histograms, Density and the Cost of a Wrong Estimate
The optimizer estimates row counts from statistics: if the value is a histogram step the estimate is exact, inside a step it is an average, and when unknown it falls back to the density vector. On 1 million Bookstore orders: reading the histogram, verifying the auto-update threshold (31,623 changes) by experiment, a plan 24 times more expensive due to the ascending key, CE models on correlated columns, and CE feedback.
Nonclustered Index Design: Key Order, INCLUDE, Covering Indexes and Key Lookups
A good nonclustered index puts equality columns before the range column in the key and carries the query's remaining columns with INCLUDE; otherwise key lookup cost makes the optimizer scan the table. Bookstore's order search query drops from 7,707 to 25 logical reads; with the tipping point, how filtered indexes interact with EF Core literals, computed columns, HasIndex equivalents and write cost measured.
Pages, Heaps and Clustered Indexes: How SQL Server Stores Data on Disk
SQL Server keeps data in 8 KB pages; a clustered index is a shallow B-tree that is the table itself, while a heap means unordered pages and forwarded records on update. Real pages, ROW_OVERFLOW/LOB, choosing a clustering key, an experiment showing Guid.CreateVersion7 values are as random as NEWID in SQL Server ordering, and fill factor and page density measurements.
A Query's Journey Inside SQL Server: Relational Engine, Storage Engine, Buffer Pool and Transaction Log
A query reaches SQL Server over TDS, is parsed, bound and optimized in the Relational Engine and lands in the plan cache; the Storage Engine reads pages through the buffer pool, and changes go to the transaction log first (WAL) and to the data file later via checkpoint. Also: the deterministic 5.6-million-row Bookstore lab data used across the series, the 2025 editions and how compatibility level differs from engine version.
DevTools and AI: Gemini AI Assistance, Chrome DevTools MCP and Recorder
The Chrome DevTools MCP server opens everything in the browser to a coding agent: without a separate profile, --no-usage-statistics and --no-performance-crux, personal sessions and URLs can leave your machine. With an agent we find and fix, via source-mapped stacks, an SPA fallback returning HTML for an API call and a NaN IndexedDB key on /books/abc; Gemini AI assistance requirements, the DevToolsGenAiSettings policy, and exporting a Recorder recording to Puppeteer.
Angular DevTools: Component Tree, Profiler, Injector Tree and Router Tree
Angular DevTools only works on development builds, and a build made with optimization: false also behaves in development mode: the Service Worker turns off and budgets are exceeded. We read Components, the Signal Graph, the Profiler, the Injector Tree and the Router Tree with real data: fixing NG0201 with a route-level provider and seeing the new Route: reviews injector, and card template updates dropping from 855 to 0 with OnPush and track book.id.
Lighthouse, Rendering and Coverage: Reading Audits Correctly
In Lighthouse 13 the audits merged with Performance Insights, but the score is calculated only from metrics: fixing cache-insight left the score unchanged, and three runs on the same page varied between 89 and 91. Simulated vs observed LCP, lab vs field data, navigation/timespan/snapshot modes, Rendering emulations, and using a source map to show that only 2.6 KB of the 42 percent in Coverage is our own code.
The Memory Panel: Heap Snapshots, Allocation Timelines and Hunting Memory Leaks in Angular
In the Memory panel you prove a leak with the three-snapshot technique and find who holds it with the retainer chain: after 10 visits, 10 BookDetail instances remained, each holding 201 kB with a shallow size of 0.0 kB. A window resize listener, a shared closure context, an array in a service and an interval never unsubscribed; detached DOM holding the whole tree, shallow vs retained size, Chrome 155–156 context analysis and the fix with takeUntilDestroyed.
The Performance Panel: Live Metrics, Recording Traces, Insights and the Angular Custom Track
The Performance panel splits an interaction into input delay, processing and presentation delay; in zoneless Angular, rendering lands in presentation delay. We measure the INP of typing into a 2000-book list filter at 712 ms on a 20x CPU and fix it with computed signals and @for track; live metrics, the flame chart, long tasks, Insights and the Angular custom track enabled with ng.enableProfiling(), with real trace data.