I have a query that takes ~20x as long for SQL server to execute when it comes from a web request, as it does from when the exact same query is ran via SQL Server Management Studio
The following screenshot is from the SQL Server Profiler. The first two records relate to the receipt and execution of query that's come in via the web request, whilst the third record is the exact same query run from SSMS. Why would there be a such a huge difference between the two?
A point: The query is generated from LINQ. I took a copy of the generated SQL and ran it in SSMS to get these results.
ARITHABORT is ON by default in SSMS and OFF by default for a SqlClient connection.
See if this solves your issue: