SQL Server Performance Issue: Parameter Sniffing, Index Fragmentation, and Outdated Statistics

Not every slow query means bad query. Faced one strange issue recently. Same stored procedure… sometimes running in milliseconds sometimes taking few seconds At first we thought data issue. Then infra. But no. Actual problem was mix of things: - Parameter sniffing - Index fragmentation - Outdated statistics Execution plan was getting cached based on first parameter. For that data it was fine. But when different data came → same plan became worst choice. On top of that: fragmented indexes = more IO old stats = optimizer making wrong guesses We did few simple things: - updated stats - rebuilt indexes - used recompile where needed No big code change. But performance became stable. Big learning for me: SQL performance is not only about query writing. It’s about how SQL Server “thinks” about your data. Sometimes issue is not in your code… it’s in the plan behind it. #SQLServer #Backend #Performance #DotNet

To view or add a comment, sign in

Explore content categories