Most of us have long been aware that non-parameterized ad-hoc queries can pollute procedure cache with entries that will never be reused. Each distinct query string is a separate cache entry and, unless the exact query with the same values is executed again, the plan will remain in cache unnecessarily until aged out.
However, I was surprised to learn recently that even parameterized queries can bloat procedure cache if one isn’t careful. This was brought to by attention by SQL Server MVP Erland Sommarskog and confirmed by fellow MVP Adam Machanic, who experienced this problem at a customer site.
The issue is...