简体   繁体   English

SQL Server ARITHABORT

[英]SQL Server ARITHABORT

I'm working with a client who has just upgraded from SQL 2000 to SQL 2008 and their view query times have gone up a lot. 我正在与一个刚刚从SQL 2000升级到SQL 2008的客户端工作,他们的查看查询时间已经增加了很多。

I had a look at the views and couldn't see much wrong with them. 我看了一下这些观点,看不出它们有多大的错误。 When I ran the view directly on the server, the times were OK. 当我直接在服务器上运行视图时,时间还可以。 When I ran via Management Studio remotely, the time goes from 2secs to about 30secs. 当我通过Management Studio远程运行时,时间从2秒到大约30秒。

So, I've tried an experiment on the test copy by setting ARITHABORT to ON (based on some articles), and the times go down remotely as well. 所以,我已经尝试通过将ARITHABORT设置为ON(基于一些文章)对测试副本进行实验,并且时间也会远程下降。

So, setting ARITHABORT seems to be the answer, but before applying to the live DB, I'd like to understand why. 因此,设置ARITHABORT似乎是答案,但在应用于实时DB之前,我想了解原因。 I get that it's to do with the level of severity of a zero divide, but why should it help with view query times? 我认为它与零鸿沟的严重程度有关,但为什么它应该有助于查看查询时间?

Tim, 蒂姆

I think that in SQL Server 2000, if you had set ARITHABORT OFF, the query optimizer wouldn't consider indexed view indexes in developing a query execution plan. 我认为在SQL Server 2000中,如果您已将ARITHABORT设置为OFF,则查询优化器在开发查询执行计划时不会考虑索引视图索引。 So if the best plan uses a view index, it would matter. 因此,如果最佳计划使用视图索引,那就很重要了。 I don't know if this is still the case, but when you look at the query plans, you could specifically look at whether the faster plan mentions a view index. 我不知道是否仍然如此,但是当你查看查询计划时,你可以专门看看更快的计划是否提到了一个视图索引。

I don't know the specific reason ARITHABORT has to do with indexed views, but SET options affect a number of things, and the situation with ARITHABORT has hardly been stable. 我不知道ARITHABORT与索引视图有关的具体原因,但SET选项会影响很多事情,ARITHABORT的情况几乎不稳定。 You might check out this link . 你可以查看这个链接

It's also not out of the question that some of this behavior is affected by the compatibility level. 这种行为中的某些行为受兼容性级别的影响也不是不可能的。 If any of the upgraded databases were set at level 80 or 90, you might see if that was really needed. 如果任何已升级的数据库设置为80或90级,您可能会看到是否真的需要这样做。

I tend to think that the ARITHABORT setting is a red herring. 我倾向于认为ARITHABORT设置是红鲱鱼。 Do your query plans differ between the test and the production systems? 您的查询计划在测试和生产系统之间是否有所不同? Are your tables IDENTICAL in the data that they contain, and are your statistics up to date on both servers, with the same indexes? 您的表在它们包含的数据中是否为IDENTICAL,并且您的统计数据是否在两台服务器上都是最新的,具有相同的索引? I would check that first. 我先检查一下。

You should always turn ArithAbort ON in your logon session for performance reasons. 出于性能原因,您应始终在登录会话中打开ArithAbort。 I just experience this issue with multiple procs on a 2008 R2 database and found that Microsoft updated the SQL server documentation for 2012 to state as such. 我刚刚在2008 R2数据库上遇到多个proc的问题,并发现Microsoft更新了2012年的SQL服务器文档,并说明了这一点。

http://msdn.microsoft.com/en-us/library/ms190306.aspx http://msdn.microsoft.com/en-us/library/ms190306.aspx

Always set ARITHABORT to ON in your logon sessions. 始终在登录会话中将ARITHABORT设置为ON。 Setting ARITHABORT to OFF can negatively impact query optimization, leading to performance issues. 将ARITHABORT设置为OFF会对查询优化产生负面影响,从而导致性能问题。

⚠️ Warning ⚠️ 警告

The default ARITHABORT setting for SQL Server Management Studio is ON. SQL Server Management Studio的默认ARITHABORT设置为ON。 Client applications setting ARITHABORT to OFF might receive different query plans, making it difficult to troubleshoot poorly performing queries. 将ARITHABORT设置为OFF的客户端应用程序可能会收到不同的查询计划,因此很难对性能较差的查询进行故障排除。 That is, the same query might execute fast in management studio but slow in the application. 也就是说,相同的查询可能在管理工作室中快速执行但在应用程序中速度较慢。 When troubleshooting queries with Management Studio, always match the client ARITHABORT setting. 使用Management Studio对查询进行故障排除时,始终匹配客户端ARITHABORT设置。

[This isn't much of an answer.] I have also just run into this, but even more strangely is that I cannot now reproduce the previously poor performance! [这不是一个很好的答案。]我也遇到过这个问题,但更奇怪的是,我现在无法再现以前糟糕的表现! Even after setting that option back to OFF, the relevant SQL is now running as fast as it was previously. 即使将该选项设置为OFF,相关SQL现在也会像以前一样快速运行。 [I suspect caching has now obviated any differences that setting conferred.] [我怀疑缓存现在已经避免了所设置的任何差异。]

When ARITHABORT is OFF , indexes on (persisted) computed columns are not used . ARITHABORTOFF不使用 (持久)计算列上的索引。 In general Microsoft recommends to always turn it ON . 一般情况下,Microsoft建议始终将其 ON The only reason it's OFF by default (in some cases) is backwards compatibility. 默认情况下(在某些情况下) OFF的唯一原因是向后兼容性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM