Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Category: SQL

SQL

SQL Performance Degrades After “Minor” Schema Changes

- 13.01.26 - ErcanOPAK comment on SQL Performance Degrades After “Minor” Schema Changes

Small change, big impact. WhyIndexes no longer match query patterns. Tip Re-evaluate indexes after schema updates.

Read More
SQL

SQL Queries Break When Data Size Changes

- 12.01.26 - ErcanOPAK comment on SQL Queries Break When Data Size Changes

Edge cases appear. WhyAssumptions about row counts. Tip Test queries with realistic data volumes.

Read More
SQL

SQL Tables Age Poorly

- 12.01.26 - ErcanOPAK comment on SQL Tables Age Poorly

Schema works… until it doesn’t. WhyNo evolution strategy. Tip Design for future columns and growth.

Read More
SQL

SQL COUNT(*) Becomes Expensive on Large Tables

- 11.01.26 - ErcanOPAK comment on SQL COUNT(*) Becomes Expensive on Large Tables

Simple query, big cost. WhyFull table scan required. Fix Maintain approximate counters when possible.

Read More
SQL

SQL Queries Slow Down After Indexing

- 11.01.26 - ErcanOPAK comment on SQL Queries Slow Down After Indexing

Index added… worse performance. WhyIndex increases write cost. Fix Index only read-heavy paths.

Read More
SQL

SQL Queries Get Slower as Data Grows

- 07.01.26 - ErcanOPAK comment on SQL Queries Get Slower as Data Grows

Worked fine for months. WhyMissing pagination strategy. Fix Always paginate user-facing queries.

Read More
SQL

SQL Indexes Exist but Queries Stay Slow

- 07.01.26 - ErcanOPAK comment on SQL Indexes Exist but Queries Stay Slow

Indexes aren’t magic. WhyIndex selectivity is too low. Fix Index columns with high cardinality.

Read More
SQL

SQL COUNT(*) Is Slower Than Expected

- 06.01.26 - ErcanOPAK comment on SQL COUNT(*) Is Slower Than Expected

Small table, big delay. WhyTable scan instead of index usage. FixUse indexed columns.

Read More
SQL

SQL Queries Slow Only After Server Restart

- 06.01.26 - ErcanOPAK comment on SQL Queries Slow Only After Server Restart

Then magically improve. WhyCold cache + outdated statistics. Fix UPDATE STATISTICS TableName;  

Read More
SQL

SQL Deadlocks Only Happen at Night

- 05.01.26 - ErcanOPAK comment on SQL Deadlocks Only Happen at Night

Daytime works fine. WhyBatch jobs compete for locks. FixLower isolation level for reporting jobs.

Read More
SQL

SQL Queries Slow After Adding Index

- 05.01.26 - ErcanOPAK comment on SQL Queries Slow After Adding Index

Counterintuitive but real. WhyOptimizer chooses suboptimal plan. FixUpdate statistics after index changes.

Read More
SQL

SQL Temp Tables Kill Performance

- 04.01.26 - ErcanOPAK comment on SQL Temp Tables Kill Performance

Works fine with small data. WhyTempDB contention. FixUse table variables for small datasets.

Read More
SQL

SQL Queries Return Wrong Results After Schema Change

- 04.01.26 - ErcanOPAK comment on 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;  

Read More
SQL

SQL Deadlocks Appear Under Load

- 03.01.26 - ErcanOPAK comment on SQL Deadlocks Appear Under Load

Works fine in testing. WhyDifferent execution order under concurrency. FixStandardize access order across queries.

Read More
SQL

SQL Queries Suddenly Ignore Indexes

- 03.01.26 - ErcanOPAK comment on SQL Queries Suddenly Ignore Indexes

Indexes exist, scans happen. WhyImplicit type conversions. Fix WHERE UserId = @UserId — matching types  

Read More
SQL

Parameter Sniffing Kills Performance

- 03.01.26 - ErcanOPAK comment on Parameter Sniffing Kills Performance

Random slow queries. WhyExecution plans cached incorrectly. Fix OPTION (RECOMPILE)  

Read More
SQL

SQL Query Slows Down as Data Grows

- 03.01.26 - ErcanOPAK comment on 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);  

Read More
SQL

SQL Index Exists but Not Used

- 02.01.26 - ErcanOPAK comment on SQL Index Exists but Not Used

Planner ignores it. WhyLow selectivity. Fix Include filtered indexes.

Read More
SQL

SQL Queries Randomly Slow Down

- 02.01.26 | 03.01.26 - ErcanOPAK comment on 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 […]

Read More
SQL

SQL COUNT(*) Isn’t Always Cheap

- 01.01.26 - ErcanOPAK comment on SQL COUNT(*) Isn’t Always Cheap

Especially on large tables. Why it happensFull scan required. TipUse metadata counts when possible.

Read More
SQL

SQL Queries Slow Down After Data Grows

- 01.01.26 - ErcanOPAK comment on SQL Queries Slow Down After Data Grows

Same query, worse performance. Why it happensMissing covering indexes. FixInclude frequently selected columns.

Read More
SQL

SQL — LIKE ‘%text%’ Forces Full Table Scan

- 31.12.25 - ErcanOPAK comment on SQL — LIKE ‘%text%’ Forces Full Table Scan

Leading wildcard kills indexes. Fix Use full-text search where possible.

Read More
SQL

SQL — ROW_NUMBER() Without Index Is Expensive

- 31.12.25 - ErcanOPAK comment on SQL — ROW_NUMBER() Without Index Is Expensive

Pagination becomes slow on big tables. Fix Index the ORDER BY column.

Read More
SQL

SQL — TRUNCATE Resets Identity Values

- 30.12.25 - ErcanOPAK comment on SQL — TRUNCATE Resets Identity Values

Many devs forget this. ❌ Impact Primary key collisions in test environments. ✅ Rule Use DELETE if identity must persist.

Read More
SQL

SQL — BETWEEN Can Return Unexpected Rows

- 30.12.25 - ErcanOPAK comment on SQL — BETWEEN Can Return Unexpected Rows

BETWEEN is inclusive on both ends. ❌ Bug Date range queries include unwanted records. ✅ Fix Use >= and < explicitly.

Read More
Development / SQL

SQL — ORDER BY Without Index Causes TempDB Spikes

- 29.12.25 - ErcanOPAK comment on SQL — ORDER BY Without Index Causes TempDB Spikes

Large sorts spill to TempDB. ✅ Fix Create supporting indexes for ORDER BY columns.

Read More
SQL

SQL — ISNULL() Can Break Index Usage

- 29.12.25 - ErcanOPAK comment on SQL — ISNULL() Can Break Index Usage

WHERE ISNULL(Deleted, 0) = 0 ❌ Effect Index seek becomes scan. ✅ Fix Rewrite conditions without functions.

Read More
SQL

Parse JSON directly in T-SQL

- 29.12.25 - ErcanOPAK comment on 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’;  

Read More
SQL

Finding Duplicates Instantly in SQL

- 29.12.25 - ErcanOPAK comment on 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;  

Read More
SQL

SQL — DELETE Without Batching Locks Tables

- 28.12.25 - ErcanOPAK comment on SQL — DELETE Without Batching Locks Tables

Large deletes = blocking. ✅ Safe pattern DELETE TOP (1000) FROM Logs Loop until rows = 0.

Read More
Page 4 of 9
« Previous 1 2 3 4 5 6 7 8 9 Next »

Posts navigation

Older posts
Newer posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (859)
  • Get the First and Last Word from a String or Sentence in SQL (837)
  • How to select distinct rows in a datatable in C# (806)
  • How to make theater mode the default for Youtube (754)
  • Add Constraint to SQL Table to ensure email contains @ (578)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (564)
  • Average of all values in a column that are not zero in SQL (531)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (489)
  • Find numbers with more than two decimal places in SQL (449)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (859)
  • Get the First and Last Word from a String or Sentence in SQL (837)
  • How to select distinct rows in a datatable in C# (806)
  • How to make theater mode the default for Youtube (754)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com