简体   繁体   English

SQL在ssms中比在应用程序中更快

[英]SQL faster in ssms than in application

One ERP system execute SQL statements very slowly. 一个ERP系统执行SQL语句的速度非常慢。 I get into activity profiler in SQL Server Management Studio and I saw that one SQL command takes 25 seconds. 我进入SQL Server Management Studio中的活动事件探查器,发现一条SQL命令花费25秒。 I run the same SQL command in Management Studio, and it takes only 3-4 seconds to get results (it's a normal select with where clause, without joins and other). 我在Management Studio中运行相同的SQL命令,并且只需要3-4秒即可获得结果(这是带有where子句的常规选择,不包含联接和其他内容)。

What can this be caused by? 这是什么原因引起的?

Welcome to SO 欢迎来到SO

I came across this issue quite recently myself. 我本人最近才遇到这个问题。 We found the cause was down to database settings in SSMS, being different to the sending APP. 我们发现原因与SSMS中的数据库设置有关,与发送的APP不同。 In SSMS right click on the database, select Proprties , and the Options . 在SSMS中,右键单击数据库,选择“ Proprties ,然后选择“ Options This gives you a list of the settings that SSMS is using. 这为您提供了SSMS使用的设置列表。

In particular we found differences in ANSI NULLS and Arith Abort . 特别是,我们发现ANSI NULLS Arith AbortArith Abort有所不同。 Debug your app and check what settings are being sent through to the server, you may well find a difference. 调试您的应用程序并检查将哪些设置发送到服务器,您可能会发现有所不同。

Settings like these can have major effects on how the server executes the query. 此类设置可能会对服务器执行查询的方式产生重大影响。

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

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