简体   繁体   English

Azure SQL查询编辑器vs Management Studio

[英]Azure SQL Query Editor vs Management Studio

I'm pretty new to azure and cloud computing in general and would like to ask your help in figuring out issue. 一般而言,我对天青和云计算还很陌生,想请您帮忙解决问题。

Issue was first seen when we had webpage that time outs due to sql timeout set to (30 seconds). 当我们将网页由于sql超时设置为(30秒)而超时时,首次发现该问题。

First thing I did was connect to the Production database using MS SQL management studio 2014 (Connected to the azure prod db) 我所做的第一件事是使用MS SQL Management Studio 2014连接到生产数据库(已连接到Azure Prod数据库)

Ran the stored procedure being used by the low performing page but got the return less than 0 seconds. 运行性能低下的页面正在使用的存储过程,但返回少于0秒。 This made me confused since what could be causing the issue. 这使我感到困惑,因为可能是引起该问题的原因。

By accident i also tried to run the same query in the Azure SQL query editor and was shock that it took 29 seconds to run it. 偶然地,我也尝试在Azure SQL查询编辑器中运行相同的查询,但震惊的是它花了29秒来运行它。

My main question is why is there a difference between running the query in azure sql query editor vs Management studio. 我的主要问题是,为什么在Azure SQL查询编辑器中运行查询与Management Studio之间会有区别? This is the exact same database. 这是完全相同的数据库。

DTU usage is at 98% and im thingking there is a performance issue with the stored proc but want to know first why sql editor is running the SP slower than Management studio. DTU的使用率为98%,并且存储的过程存在性能问题,但首先想知道为什么sql editor运行SP的速度比Management Studio慢。

Current azure db has 50 dtu's. 当前的天蓝色db有50 dtu。

Two guesses (posting query plans will help get you an answer for situations like this): 两个猜想(发布查询计划将帮助您为此类情况提供答案):

  1. SQL Server has various session-level settings. SQL Server具有各种会话级设置。 For example, there is one to determine if you should use ansi_nulls behavior (vs. the prior setting from very old versions of SQL Server). 例如,可以使用一种方法来确定是否应使用ansi_nulls行为(相对于SQL Server的较旧版本中的先前设置)。 There are others for how identifiers are quoted and similar. 还有其他关于如何引用标识符和类似标识符的方法。 Due to legacy reasons, some of the drivers have different default settings. 由于遗留原因,某些驱动程序具有不同的默认设置。 These different settings can impact which query plans get chosen, in the limit. 这些不同的设置可能会影响选择的查询计划。 While they won't always impact performance, there is a chance that you get a scan instead of a seek on some query of interest to you. 尽管它们并不总是会影响性能,但是您有可能获得扫描而不是寻找您感兴趣的查询。

  2. The other main possible path for explaining this kind of issue is that you have a parameter sniffing difference. 解释此类问题的另一种主要途径是您有一个参数嗅探差异。 SQL's optimizer will peek into the parameter values used to pick a better plan (hoping that the value will represent the average use case for future parameter values). SQL的优化器将窥视用于选择更好计划的参数值(希望该值代表将来参数值的平均用例)。 Oracle calls this bind peeking - SQL calls it parameter sniffing. Oracle将此称为绑定窥视-SQL将其称为参数嗅探。 Here's the post I did on this some time ago that goes through some examples: https://blogs.msdn.microsoft.com/queryoptteam/2006/03/31/i-smell-a-parameter/ 这是我前一段时间在此发表的帖子,其中包含一些示例: https : //blogs.msdn.microsoft.com/queryoptteam/2006/03/31/i-smell-a-parameter/

I recommend you do your experiments and then look at the query store to see if there are different queries or different plans being picked. 我建议您进行实验,然后查看查询存储以查看是否有不同的查询或不同的计划被选择。 You can learn about the query store and the SSMS UI here: https://docs.microsoft.com/en-us/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store?view=sql-server-2017 您可以在此处了解查询存储和SSMS UI: https ://docs.microsoft.com/zh-cn/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store?view = SQL服务器-2017

For this specific case, please note that the query store exposes those different session-level settings using "context settings". 对于这种特定情况,请注意查询存储使用“上下文设置”公开那些不同的会话级设置。 Each unique combination of context settings will show up as a different context settings id, and this will inform how query texts are interpreted. 上下文设置的每个唯一组合将显示为不同的上下文设置id,这将通知如何解释查询文本。 In query store parlance, the same query text can be interpreted different ways under different context settings, so two different context settings for the same query text would imply two semantically different queries. 用查询存储的说法,可以在不同的上下文设置下以不同的方式解释相同的查询文本,因此同一查询文本的两个不同的上下文设置将意味着两个语义上不同的查询。

Hope that helps - best of luck on your perf problem 希望对您有帮助-最好解决您的性能问题

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

相关问题 SQL Azure数据库管理控制台与本地SQL Management Studio - SQL Azure Database Management Console vs Local SQL Management Studio 阻止查询编辑器改变SQL Server Management Studio中的视图 - Block Query Editor from altering views in SQL Server Management Studio SSIS查询不会在Execute Sql Task Editor中更新,但会在sql Server Management Studio中更新 - SSIS query doesn't update in Execute Sql Task Editor but updates in sql server management studio SQL Management Studio 2008 - 查询编辑器选项卡上的服务器名称......它们去了哪里? - SQL Management Studio 2008 - Server name on Query Editor tabs…where did they go? SQL Management Studio无法将表/对象从Explorer拖动到查询编辑器 - SQL Management Studio can't drag table / object from Explorer to Query Editor Azure表和SQL Server Management Studio - Azure Tables and SQL Server Management Studio 无法连接到 SQL Server Management Studio 中的 Azure - Cannot connect to Azure in SQL Server Management Studio SQL Server Management Studio与其他版本 - SQL Server Management studio vs other editions VS2010的SQL Server Management Studio - SQL Server Management Studio For VS2010 来自 Management Studio 与 EF Core 5 的 SQL 服务器查询的不同性能 - Different performance from SQL Server query from Management Studio vs EF Core 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM