I have had, more than once, the problem that a complex query, when executed through a SqlCommand
from a .NET application, behaves differently performance-wise than a query that is executed in SSMS. When I encounter these issues, the SqlCommand
is always slower than queries run in SSMS, against the same database. Most notable are execution times of 3 seconds vs 150 ms, and 30 seconds vs. 70 ms.
What issues does the SqlCommand
have that make it slower than queries run in SSMS?