Conditional aggregation performance

Short summary Performance of subqueries method depends on the data distribution. Performance of conditional aggregation does not depend on the data distribution. Subqueries method can be faster or slower than conditional aggregation, it depends on the data distribution. Naturally, if the table has a suitable index, then subqueries are likely to benefit from it, because … Read more

Query times out when executed from web, but super-fast when executed from SSMS

So your C# code is sending an ad hoc SQL query to SQL Server, using what method? Have you considered using a stored procedure? That would probably ensure the same performance (at least in the engine) regardless of who called it. Why? The ARITHABORT setting is one of the things the optimizer looks at when … Read more