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

Why SELECT * Destroys Query Performance Over Time

- 30.01.26 - ErcanOPAK comment on Why SELECT * Destroys Query Performance Over Time

Today it’s fine. Tomorrow it’s slow. Why Schema changes Wider rows More IO Fix Select only what you need. SELECT Id, Name FROM Users;  

Read More
SQL

Indexes Can Make Queries Slower (Here’s Why)

- 29.01.26 - ErcanOPAK comment on Indexes Can Make Queries Slower (Here’s Why)

Too many indexes = slower writes. Why Every INSERT/UPDATE must update all indexes. Rule Indexes are not free. Audit sys.dm_db_index_usage_stats  

Read More
SQL

Why SELECT * Slowly Destroys Performance

- 29.01.26 - ErcanOPAK comment on Why SELECT * Slowly Destroys Performance

It’s not about bandwidth — it’s about execution plans. Problems Wider rows = more IO Breaks covering indexes Schema changes silently hurt queries Fix Always project explicitly: SELECT Id, Name, CreatedAt FROM Users;  

Read More
SQL

Avoid SELECT * in Production

- 28.01.26 - ErcanOPAK comment on Avoid SELECT * in Production

Why it mattersSchema changes won’t silently break performance.

Read More
SQL

Covering Indexes Reduce Lookups

- 28.01.26 - ErcanOPAK comment on Covering Indexes Reduce Lookups

INCLUDE (Name, Email) Why it mattersQueries hit index only → faster reads.

Read More
SQL

Use EXISTS Instead of COUNT(*)

- 27.01.26 - ErcanOPAK comment on Use EXISTS Instead of COUNT(*)

Why it mattersStops scanning once a match is found.

Read More
SQL

Partial Indexes Save Space

- 27.01.26 - ErcanOPAK comment on Partial Indexes Save Space

CREATE INDEX idx_active_users ON Users(Id) WHERE IsActive = 1; Why it mattersIndex only what you query.

Read More
SQL

Avoid SELECT *

- 26.01.26 - ErcanOPAK comment on Avoid SELECT *

Why it mattersBreaks caching, increases IO, hides schema drift.

Read More
SQL

Covering Indexes Prevent Lookups

- 26.01.26 - ErcanOPAK comment on Covering Indexes Prevent Lookups

CREATE INDEX IX_User_Email ON Users (Email) INCLUDE (Name); Why it mattersFewer disk reads = faster queries.

Read More
SQL

Use EXISTS Instead of IN for Better Query Plans

- 25.01.26 - ErcanOPAK comment on Use EXISTS Instead of IN for Better Query Plans

SELECT * FROM Users u WHERE EXISTS ( SELECT 1 FROM Orders o WHERE o.UserId = u.Id ); Why this mattersEXISTS short-circuits; IN often materializes full sets.

Read More
SQL

Why COUNT(*) Can Be Slow on Large Tables

- 25.01.26 - ErcanOPAK comment on Why COUNT(*) Can Be Slow on Large Tables

Counting rows forces full scans. SELECT COUNT_BIG(*) FROM Orders WITH (NOLOCK); Why this mattersOn massive tables, counts are expensive — cache or approximate when possible.

Read More
SQL

The Hidden Cost of OFFSET Pagination

- 24.01.26 - ErcanOPAK comment on The Hidden Cost of OFFSET Pagination

Large offsets force the database to scan and discard rows. SELECT * FROM Orders WHERE Id > @LastSeenId ORDER BY Id FETCH NEXT 20 ROWS ONLY; Why this worksKeyset pagination scales infinitely.

Read More
SQL

Why SELECT * Slowly Destroys Performance

- 24.01.26 - ErcanOPAK comment on Why SELECT * Slowly Destroys Performance

Indexes don’t help when you ask for everything. SELECT Id, Name FROM Users WHERE IsActive = 1; Why this mattersSmaller payload, better index usage, faster IO.

Read More
SQL

Why EXISTS Beats COUNT(*) in Conditional Queries

- 24.01.26 - ErcanOPAK comment on Why EXISTS Beats COUNT(*) in Conditional Queries

You don’t need numbers when you only need truth. IF EXISTS ( SELECT 1 FROM Orders WHERE CustomerId = 42 ) BEGIN PRINT ‘Has orders’ END Why it’s faster Stops at the first match Avoids full scans Reduces CPU usage

Read More
SQL

Why SELECT * Is a Silent Performance Killer (Even With Indexes)

- 24.01.26 - ErcanOPAK comment on Why SELECT * Is a Silent Performance Killer (Even With Indexes)

Databases return exactly what you ask for.SELECT * forces unnecessary IO, memory usage, and network transfer. SELECT OrderId, OrderDate, TotalAmount FROM Orders WHERE CustomerId = 42; Cause → Effect Extra columns → wider rows → slower queries Explicit columns → faster reads + stable schemas Bonus: Schema changes won’t break consumers.

Read More
SQL

SQL COUNT(*) Slows Down Reports

- 23.01.26 - ErcanOPAK comment on SQL COUNT(*) Slows Down Reports

Simple count, slow execution. Why it happensFull table scan. Why it mattersReports lag. Vital fix Use indexed counts when possible.

Read More
SQL

SQL Index Exists but Is Ignored

- 23.01.26 - ErcanOPAK comment on SQL Index Exists but Is Ignored

Planner avoids it. Why it happensLow selectivity. Why it mattersSlow queries. Vital fix Index columns with high cardinality.

Read More
SQL

SQL Date Comparisons Kill Indexes

- 22.01.26 - ErcanOPAK comment on SQL Date Comparisons Kill Indexes

Indexes exist, unused. Why it happensFunctions on columns. Why it mattersFull table scans. Smart fixCompare ranges instead. WHERE CreatedAt >= ‘2024-01-01’ AND CreatedAt < ‘2024-02-01’  

Read More
SQL

SQL Queries Slow After Index Added

- 22.01.26 - ErcanOPAK comment on SQL Queries Slow After Index Added

Index made it worse. Why it happensWrong column order. Why it mattersOptimizer chooses bad plans. Smart fixIndex on filter columns first.

Read More
SQL

SQL NULL Handling Breaks Logic

- 21.01.26 - ErcanOPAK comment on SQL NULL Handling Breaks Logic

Counts don’t match reality. Why it happensNULL is not zero. Why it mattersBusiness logic errors. Smart fixAlways handle NULL explicitly. COALESCE(value, 0)  

Read More
SQL

SQL Queries Slow Down Over Time

- 21.01.26 - ErcanOPAK comment on SQL Queries Slow Down Over Time

Same query, worse performance. Why it happensStatistics become outdated. Why it mattersQuery plans degrade. Smart fixUpdate statistics regularly.

Read More
SQL

SQL Deletes Lock Tables

- 18.01.26 - ErcanOPAK comment on SQL Deletes Lock Tables

Simple delete, big impact. WhyLarge batch deletes. TipDelete in chunks. DELETE TOP (1000) FROM Logs;  

Read More
SQL

SQL Queries Slow Despite Indexes

- 18.01.26 - ErcanOPAK comment on SQL Queries Slow Despite Indexes

Indexes exist, still slow. WhyFunctions used on indexed columns. TipAvoid wrapping indexed columns. WHERE CreatedDate >= ‘2025-01-01’  

Read More
SQL

SQL Deadlocks Appear Sporadically

- 16.01.26 - ErcanOPAK comment on SQL Deadlocks Appear Sporadically

Hard to reproduce. WhyInconsistent access order. TipStandardize table access order.

Read More
SQL

SQL Queries Break After Schema Changes

- 16.01.26 - ErcanOPAK comment on SQL Queries Break After Schema Changes

Query logic unchanged. WhyImplicit column order dependency. TipAlways specify column names.

Read More
SQL

SQL Queries Return Correct Data Too Slowly

- 15.01.26 - ErcanOPAK comment on SQL Queries Return Correct Data Too Slowly

Logic fine, execution heavy. WhyMissing covering indexes. TipInclude frequently selected columns.

Read More
SQL

SQL Performance Drops After Adding “Helpful” Indexes

- 15.01.26 - ErcanOPAK comment on SQL Performance Drops After Adding “Helpful” Indexes

Index count rises, speed drops. WhyWrite amplification. TipIndex only what queries actually use.

Read More
SQL

SQL Performance Depends on Data Shape

- 14.01.26 - ErcanOPAK comment on SQL Performance Depends on Data Shape

Same query, different speed. WhyData distribution changes execution plans. TipReview execution plans regularly.

Read More
SQL

SQL Tables Age Worse Than Code

- 14.01.26 - ErcanOPAK comment on SQL Tables Age Worse Than Code

Schema works until it doesn’t. WhyNo room for evolution. TipDesign columns with future growth in mind.

Read More
SQL

SQL Queries Break at Scale

- 13.01.26 - ErcanOPAK comment on SQL Queries Break at Scale

Worked fine in staging. WhyProduction data distribution differs. Tip Test with production-like data sizes.

Read More
Page 3 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 (836)
  • How to select distinct rows in a datatable in C# (805)
  • 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 (448)

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 (836)
  • How to select distinct rows in a datatable in C# (805)
  • 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