Lynn Pettis - Tuesday, December 19, 2017 3:19 PM
On that note, also check how it is being cached. While poorly written and non-parameterized dynamic SQL may execute very quickly, it may have to compile each and every time it occurs. We had such a thing... it was executing in 100ms (which is still about 10-20 times longer than it needed to) but it was taking between 2 and 22 SECONDS to compile and it had to compile on every call and it was being called an insane number of times every hour.
--Jeff Moden
Change is inevitable... Change for the better is not.