Great article on stored proc performance in app vs SSMS

I’ve have occasional issues with some reports where the report will timeout running in the app, but the report stored proc returns in less than a second when I run it in SSMS with the same parameters. I realized a while ago that recompiling the stored proc will fix the issue, but today I found an article that explains why this happens (spoiler: it’s because of cached execution plans & parameter sniffing). So here’s the article – it’s a long read, but it might come in handy for you:

http://www.sommarskog.se/query-plan-mysteries.html