It’s not the count.It’s locking + metadata access. Reality COUNT must respect: Isolation level Pending writes Allocation metadata Production alternative Use approximate counts for dashboards. Why Accuracy isn’t always worth blocking.
Tag: sql-performance
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;
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;
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
