I’ve spent a bit of time talking about how IF branches can break query performance really badly in SQL Server.
Category: IF Branching
SQL Server IF Branches And Query Performance Part 5: Does Dynamic SQL Work?
If we want to start this post in the right place, we have to go back to 2009. That was the first time a (much) young(er) Erik Darling wrote dynamic SQL…
Read the post: SQL Server IF Branches And Query Performance Part 5: Does Dynamic SQL Work?
SQL Server IF Branches And Query Performance Part 4: Do Stored Procedures Work?
You know and I know and everyone knows that stored procedures are wonderful things that let you tune queries in magickal ways that stupid ORMs and ad hoc…
Read the post: SQL Server IF Branches And Query Performance Part 4: Do Stored Procedures Work?
SQL Server IF Branches And Query Performance Part 3: Local Variables Still Suck
Parameters get a bad name. It seems everything that gets sniffed does, whether it’s a stored procedure, a piece of anatomy, or an illicit substance.
Read the post: SQL Server IF Branches And Query Performance Part 3: Local Variables Still Suck
SQL Server IF Branches And Query Performance Part 2: Trying To Fix Parameters Doesn’t Work
Everyone thinks they’ve outsmarted the optimizer. All the time.
SQL Server IF Branches And Query Performance Part 1: The Problem
This is a problem I deal with quite a bit when helping people track down performance problems and, you know, solve them.
Read the post: SQL Server IF Branches And Query Performance Part 1: The Problem
Software Vendor Mistakes With SQL Server: IF Branching In Stored Procedures
I still see people calling into this trap when writing stored procedures. What no one seems to realize until it’s too late data grows past a toy data base…
Read the post: Software Vendor Mistakes With SQL Server: IF Branching In Stored Procedures
Starting SQL: Why Not Make Every SQL Server Query Dynamic SQL?
I think it was Doug Lane who coined the stages of dynamic SQL. One of them dealt with the fact that once you start using it, you just wanna use it…
Read the post: Starting SQL: Why Not Make Every SQL Server Query Dynamic SQL?
SQL Server’s Not Very Mighty IF Branch
Okay, so like, an IF branch in a stored procedure can be helpful to control logic, but not to control performance.