How (not) to abuse the plan cache with parameters
This is the 5th in a series of posts about query plans. The first post covered what a query plan is and how to read it. The second post described the effort required to make a query plan. The third entry explained how the plans are stored in a cache to be reused. The 4th post showed how the optimizer finds appropriate plans in cache. This post will cover how poor coding practices can lead to excessive plans being stored in the cache. Plans are found in cache to be reused only when an exact match of the SQL query is found. This works great until constant valuesRead More →