The query is a single select containing a lot of grouping levels and aggragate operations. With SET ARITHABORT ON is takes less than a second, otherwise it takes several minutes. We have seen this behavior on SQL Server 2000 and 2008.
migrated from stackoverflow.com Dec 28 '11 at 12:26
|
A little dated, but for anyone ending up here with a similar problem... I had the same problem. For me it turned out to be parameter sniffing, which at first I didn't understand enough to care about. I added a 'set arithabort on' which fixed the problem but then it came back. Then I read: http://www.sommarskog.se/query-plan-mysteries.html It cleared -everything- up. Because I was using Linq to SQL and had limited options to fix the issue, I ended up using a query plan guide (see end of link) to force the query plan I wanted. |
|||
|
|
|
.NET applications connect with the option disabled by default, but it's enabled by default in Management Studio. The result is that the server actually caches 2 separate execution plans for most/all procedures. This affects how the server performs numerical calculations and as such you can get wildly different results depending on the procedure. This is really only one of 2 common ways a proc can get fed a terrible execution plan, the other being parameter sniffing. Take a look at http://sqladvice.com/blogs/gstark/archive/2008/02/12/Arithabort-Option-Effects-Stored-Procedure-Performance.aspx for a little more discussion on it. |
|||||||||||||
|
|
I would argue that this was almost certainly parameter sniffing. It is often stated that In this case (for SQL2005+ and unless your database is in SQL2000 compatibility mode). If you have both The claim in Ben's answer that "the way the server performs numerical calculations" can add minutes to a result that would otherwise take less than a second just doesn't seem credible to me. I think what tends to happen is that upon investigating a performance performance problem Profiler is used to identify the offending query. This is pasted into management studio and run and returns results instantly. The only apparent difference between connections is the A quick test in a management studio window shows that when However that ignores the fact that with that option set you will end up getting the exact same bad plan from the cache. Even if you are logged in as a different user than the application connection uses. I tested this by executing a test query first from a web application then from management studio with
|
|||
|