Small change, big impact. WhyIndexes no longer match query patterns. Tip Re-evaluate indexes after schema updates.
Category: SQL
SQL Queries Break When Data Size Changes
Edge cases appear. WhyAssumptions about row counts. Tip Test queries with realistic data volumes.
SQL Tables Age Poorly
Schema works… until it doesn’t. WhyNo evolution strategy. Tip Design for future columns and growth.
SQL COUNT(*) Becomes Expensive on Large Tables
Simple query, big cost. WhyFull table scan required. Fix Maintain approximate counters when possible.
SQL Queries Slow Down After Indexing
Index added… worse performance. WhyIndex increases write cost. Fix Index only read-heavy paths.
SQL Queries Get Slower as Data Grows
Worked fine for months. WhyMissing pagination strategy. Fix Always paginate user-facing queries.
SQL Indexes Exist but Queries Stay Slow
Indexes aren’t magic. WhyIndex selectivity is too low. Fix Index columns with high cardinality.
SQL COUNT(*) Is Slower Than Expected
Small table, big delay. WhyTable scan instead of index usage. FixUse indexed columns.
SQL Queries Slow Only After Server Restart
Then magically improve. WhyCold cache + outdated statistics. Fix UPDATE STATISTICS TableName;
SQL Deadlocks Only Happen at Night
Daytime works fine. WhyBatch jobs compete for locks. FixLower isolation level for reporting jobs.
SQL Queries Slow After Adding Index
Counterintuitive but real. WhyOptimizer chooses suboptimal plan. FixUpdate statistics after index changes.
SQL Temp Tables Kill Performance
Works fine with small data. WhyTempDB contention. FixUse table variables for small datasets.
SQL Queries Return Wrong Results After Schema Change
Data exists but isn’t returned. WhyImplicit joins break after column changes. Fix SELECT … FROM A INNER JOIN B ON A.Id = B.AId;
SQL Deadlocks Appear Under Load
Works fine in testing. WhyDifferent execution order under concurrency. FixStandardize access order across queries.
SQL Queries Suddenly Ignore Indexes
Indexes exist, scans happen. WhyImplicit type conversions. Fix WHERE UserId = @UserId — matching types
Parameter Sniffing Kills Performance
Random slow queries. WhyExecution plans cached incorrectly. Fix OPTION (RECOMPILE)
SQL Query Slows Down as Data Grows
Same query, worse performance. WhyMissing covering indexes. Fix CREATE INDEX IX_User_Email ON Users (Email) INCLUDE (Name, CreatedAt);
SQL Index Exists but Not Used
Planner ignores it. WhyLow selectivity. Fix Include filtered indexes.
SQL Queries Randomly Slow Down
Same query, different speed. WhyParameter sniffing. Fix Use OPTION (RECOMPILE) selectively. 🐌 Same Query, Different Speed Nothing changed. Except the parameters. If a query sometimes runs in 10 ms and sometimes in 10 seconds,you’re probably not looking at a missing index. You’re looking at parameter sniffing. 🚨 The Core Problem SQL Server creates an execution […]
SQL COUNT(*) Isn’t Always Cheap
Especially on large tables. Why it happensFull scan required. TipUse metadata counts when possible.
SQL Queries Slow Down After Data Grows
Same query, worse performance. Why it happensMissing covering indexes. FixInclude frequently selected columns.
SQL — LIKE ‘%text%’ Forces Full Table Scan
Leading wildcard kills indexes. Fix Use full-text search where possible.
SQL — ROW_NUMBER() Without Index Is Expensive
Pagination becomes slow on big tables. Fix Index the ORDER BY column.
SQL — TRUNCATE Resets Identity Values
Many devs forget this. ❌ Impact Primary key collisions in test environments. ✅ Rule Use DELETE if identity must persist.
SQL — BETWEEN Can Return Unexpected Rows
BETWEEN is inclusive on both ends. ❌ Bug Date range queries include unwanted records. ✅ Fix Use >= and < explicitly.
SQL — ORDER BY Without Index Causes TempDB Spikes
Large sorts spill to TempDB. ✅ Fix Create supporting indexes for ORDER BY columns.
SQL — ISNULL() Can Break Index Usage
WHERE ISNULL(Deleted, 0) = 0 ❌ Effect Index seek becomes scan. ✅ Fix Rewrite conditions without functions.
Parse JSON directly in T-SQL
The Problem: You stored a JSON blob in a text column and need to query a specific property without writing a backend script. The Fix: Use OPENJSON or JSON_VALUE (SQL Server 2016+). — Extract specific property from JSON column SELECT JSON_VALUE(SettingsColumn, ‘$.theme’) AS UserTheme FROM UserPreferences WHERE JSON_VALUE(SettingsColumn, ‘$.isActive’) = ‘true’;
Finding Duplicates Instantly in SQL
The Problem: You have duplicate rows in a table and you need to identify them immediately. The Fix: Use GROUP BY and HAVING to isolate records appearing more than once. SELECT Email, COUNT(*) as Count FROM Users GROUP BY Email HAVING COUNT(*) > 1;
SQL — DELETE Without Batching Locks Tables
Large deletes = blocking. ✅ Safe pattern DELETE TOP (1000) FROM Logs Loop until rows = 0.
