sql执行组件是灰色的

In the previous articles of this series, SQL Server Execution Plans overview and SQL Server Execution Plans types we went through the different stages that the submitted SQL Server query followed and how it processed by the SQL Server Relational Engine that generates the Execution Plan and the SQL Server Storage Engine that performs the requested data retrieval or modification operation. In addition, we described deeply the different types and formats of the SQL Server Execution Plans that can be used for queries performance troubleshooting purposes. In this article, we will discuss the graphical query plan components and how to analyze it.

在本系列的前几篇文章中, SQL Server执行计划概述和SQL Server执行计划类型我们经历了提交SQL Server查询所遵循的不同阶段,以及由生成执行计划和SQLSQL Server关系引擎如何对其进行处理服务器存储引擎,执行请求的数据检索或修改操作。 此外,我们深入描述了可用于查询性能故障排除目的SQL Server执行计划的不同类型和格式。 在本文中,我们将讨论图形查询计划组件以及如何对其进行分析。

The SQL Execution Plan is used widely in tuning the performance of the queries by monitoring and troubleshooting how the query executed internally. To be able to take benefits of the SQL execution plan, we need to understand the different information provided by the SQL execution plan, clear at the surface or hidden between the operators. Recall that you should be grated SHOWPLAN permission in order to generate the Execution Plan. Members of the SYSADMIN, DBCREATOR or DB_OWNER will be able to generate the Execution Plans without the need for any extra permissions.

通过监视和解决内部查询的执行方式并对其进行故障排除,SQL执行计划被广泛用于调整查询的性能。 为了能够利用SQL执行计划,我们需要了解SQL执行计划提供的不同信息,这些信息在表面清晰可见,或者在操作员之间隐藏。 回想一下,您应该被授予SHOWPLAN权限才能生成执行计划。 SYSADMIN,DBCREATOR或DB_OWNER的成员将能够生成执行计划,而无需任何其他权限。

Let us start with a simple SQL Execution Plan. The below SQL Execution Plan is an Actual Plan generated after executing a simple SELECT statement. You may ask, how can I guess if it is an Actual Execution Plan or an Estimated Execution Plan. The answer is the Results tab that can be shown in the top of the figure, indicating that the query was executed before generating the Plan. If this part is removed from the plan, nothing can tell us from the first view what is the type of this graphical execution plan.

让我们从一个简单SQL执行计划开始。 下面SQL执行计划是在执行简单的SELECT语句后生成的实际计划。 您可能会问,我怎么能猜到它是实际执行计划还是估计执行计划。 答案是“结果”选项卡,该选项卡可以显示在图的顶部,指示该查询是在生成计划之前执行的。 如果将这部分从计划中删除,则从第一视图中什么也无法告诉我们该图形执行计划的类型。

The upper part of the SQL execution plan shows the cost of this query relative to the overall batch cost, in the case of generating the execution plan for multiple queries in the same session, as shown below:

在为同一会话中的多个查询生成执行计划的情况下,SQL执行计划的上部显示此查询相对于总批处理成本的查询成本,如下所示:

The statement of the submitted query will be also displayed at the top of the SQL execution plan. For long queries, as much of the query statement that can fit into the window will be displayed. You can get the complete statement of the query, in a new window, by clicking on the dotted square as shown below:

所提交查询的语句也将显示在SQL执行计划的顶部。 对于长查询,将显示尽可能多的查询语句。 您可以在新窗口中通过单击如下所示的虚线方框来获得查询的完整语句:

In some cases, the SQL Server Query Optimizer suggests an index, Missing Index, that it finds it will enhance the performance of the query in a specific percentage, that will be displayed as recommendation in green as shown below:

在某些情况下,SQL Server查询优化器建议使用索引Missing Index,它发现它会以特定百分比增强查询性能,该建议将以绿色显示,如下所示:

With the ability to view the CREATE INDEX statement by clicking on the Missing Index Details option, as below:

通过单击“缺少索引详细信息”选项,可以查看CREATE INDEX语句,如下所示:

For now, we have a good understanding of the upper part of the graphical Execution Plan, above the solid line. Let us start investigating the information shown lower of that line. To read the SQL Execution Plan correctly, you should know first that the flow of the execution is starting from the right to the left and from the top to the bottom, with the last operator at the left, which is the SELECT operator in most queries, contains the final result of the query. We will discuss all the operators that you may see in the Execution Plans in details later in the series.

现在,我们对图形执行计划的上方实线有了很好的了解。 让我们开始调查该行下方显示的信息。 要正确阅读SQL执行计划,首先应该知道执行的流程是从右到左,从上到下 ,最后一个运算符在左边,这是大多数查询中的SELECT运算符。 ,包含查询的最终结果。 我们将在本系列的后面部分详细讨论您可能会在执行计划中看到的所有运算符。

The arrows between the operators represent the direction and the amount of the data passed between these operators in the SQL Execution Plan. The thickness of the arrow indicates the amount of data passed between the operators. You can derive from the below figure that the amount of data passed in the second arrow is larger than the amount of data passed in the first arrow:

运算符之间的箭头表示SQL执行计划中这些运算符之间传递的数据的方向和数量。 箭头的粗细表示在运算符之间传递的数据量。 从下图可以得出,第二个箭头中传递的数据量大于第一个箭头中传递的数据量:

You can get the amount of data passed through this arrow from the arrow tooltip by pointing the mouse to that arrow as shown below:

通过将鼠标指向该箭头,可以从箭头工具提示中获取通过该箭头传递的数据量,如下所示:

Not only the number of rows passed by the arrow can be derived by the arrow, but also other useful information is hidden behind this arrow. This information includes the size of the each passed row and the total size of the data that is passed through the arrow. The thickness of the arrow can also be an indication of a performance issue. For example, if the execution plan shows a thick arrows, the number of the rows that are passed through the arrows is large, at the beginning of the plan and the number of rows passed through the last arrow to the SELECT statement and returned by the query is small then a scan operation is performed incorrectly to a table or an index that should be fixed.

箭头不仅可以导出箭头传递的行数,而且其他有用的信息也隐藏在该箭头的后面。 此信息包括每个传递的行的大小以及通过箭头传递的数据的总大小。 箭头的粗细也可以指示性能问题。 例如,如果执行计划显示粗箭头,则在计划开始时,通过箭头的行数很大,并且通过最后一个箭头传递到SELECT语句并由SELECT返回的行数。查询很小,则对应该固定的表或索引执行的扫描操作不正确。

Below each operator, a number as percentage, that represents the SQL Server Query Optimizer estimation for the cost of that operator with relative to the overall query cost, will be displayed. In our example, you can see that all the estimated cost is related to the Clustered Index Seek operator, as shown below:

在每个运算符的下方,将显示一个百分比数字,该数字表示SQL Server查询优化程序对该运算符的成本相对于整体查询成本的估计。 在我们的示例中,您可以看到所有估计的成本都与“聚簇索引查找”运算符相关,如下所示:

When using the ApexSQL Plan, a free tool for SQL execution plan viewing and analysis, the important numbers that represent the top statistics of each operator and arrow will be displayed without the need to click on the component, as shown below:

使用ApexSQL Plan(一种用于查看和分析SQL执行计划的免费工具)时,无需单击组件即可显示代表每个操作员和箭头的顶级统计信息的重要数字,如下所示:

Is that everything can be derived from the Execution Plan? The answer for sure no. There is other information hidden behind each operator in the Execution Plan. Just point the mouse over any operator in the plan, the tooltip for that operator, that contains statistical information and full description about the operator, will be displayed. For example, if you hold the mouse pointer over the Clustered Index Seek operator, the tooltip of that operator will be displayed.

一切都可以从执行计划中得出吗? 肯定没有答案。 执行计划中每个操作员的后面都隐藏着其他信息。 只需将鼠标悬停在计划中的任何操作员上,就会显示该操作员的工具提示,其中包含统计信息和有关该操作员的完整说明。 例如,如果将鼠标指针停留在“聚集索引查找”运算符上,将显示该运算符的工具提示。

The displayed pop-up contains:

显示的弹出窗口包含:

  • The definition of the selected operator as below:

    所选运算符的定义如下:

  • Statistical information about the operator, such as the I/O and CPU costs. These numbers don’t represent the actual amount of resources consumed by this operator, it represents an estimated cost assigned by the SQL Server Query Optimizer during the execution. These information helps to understand what is happening internally while executing the query, as shown below:

    有关操作员的统计信息,例如I / O和CPU成本。 这些数字并不代表此运算符消耗的实际资源量,而是代表执行期间SQL Server查询优化器分配的估计成本。 这些信息有助于了解执行查询时内部发生的情况,如下所示:

We usually concentrate on the subtree cost of the operator that represents the execution tree that the SQL Server Engine has looked at so far, from right to left, and top to bottom. In the complex plans, that consists of large number of operators, the full cost of the plan can be derived from the final operation accumulatively, which is the SELECT operator in our case.

我们通常集中在运算符的子树成本上,该运算符表示SQL Server Engine到目前为止(从右到左,从上到下)查看的执行树。 在由大量运算符组成的复杂计划中,计划的全部成本可以累积自最终操作,在本例中为SELECT运算符。

You should also give attention to the Ordered Boolean value in the operator tooltip. This value indicates if the data that the current operator is processing is sorted or not, which help to show why an extra processing is required in that step of the query. The Node ID value represents the numbered order of the operator assigned by the SQL Server Query Optimizer.

您还应该注意操作员工具提示中的Ordered Boolean值。 此值指示是否对当前运算符正在处理的数据进行了排序,这有助于显示为什么在查询的该步骤中需要额外的处理。 节点ID值表示由SQL Server查询优化器分配的运算符的编号顺序。

The Actual execution Plan operator displays Actual and Estimated statistics. On the other hand, the Estimated Execution Plan displays only Estimated statistics. In most cases, the Actual and Estimated values are identical. If not, then the statistics of that database table or index are outdated and should be updated, as shown below:

实际执行计划操作员显示实际和估计的统计信息。 另一方面,“估计执行计划”仅显示“估计”统计信息。 在大多数情况下,实际值和估计值是相同的。 如果不是,则该数据库表或索引的统计信息已过时,应进行更新,如下所示:

The properties window of the operator provides us with extra information that is not listed in the operator tooltip. If you right-click on any operator and choose Properties window, or just click on the operator and click F4, the properties window of that operator will be displayed. The displayed window will show us more useful information that represents the how the SQL Server will behave while processing the data within that operator. Clicking on the property will display a description for that property, for most of properties but not all, that makes it easier to understand it. The properties with (+) sign beside it are expandable properties that can display extra information, as shown below:

操作员的属性窗口为我们提供了操作员工具提示中未列出的其他信息。 如果右键单击任何运算符并选择“属性”窗口,或者仅单击该运算符并单击F4,将显示该运算符的属性窗口。 显示的窗口将向我们显示更多有用的信息,这些信息表示SQL Server在该运算符中处理数据时的行为。 单击该属性将显示该属性的描述,对于大多数属性,但不是全部,这使它更易于理解。 旁边带有(+)号的属性是可扩展属性,可以显示更多信息,如下所示:

For now, we got a good understanding of the SQL Execution Plan components and how to read it from the right to the left, from the top to the bottom, and that we need to concentrate on the higher percentage operator, the thickest arrow, largest subtree cost, not ordered data, the SCAN operators …etc.

到目前为止,我们对SQL执行计划组件以及如何从右到左,从上到下读取它有了很好的了解,并且我们需要集中精力于百分比较高的运算符,最粗的箭头,最大的子树成本,而不是有序数据,SCAN运营商……等等。

In the next article, we will start by introducing the first set of Execution Plans operators. Stay tuned!

在下一篇文章中,我们将介绍第一套执行计划运算符。 敬请关注!

目录 (Table of contents)

SQL Server Execution Plans Overview
SQL Server Execution Plans Types
How to Analyze SQL Execution Plan Graphical Components
SQL Server Execution Plans Operators – Part 1
SQL Server Execution Plans Operators – Part 2
SQL Server Execution Plans Operators – Part 3
SQL Server Execution Plans Operators – Part 4
SQL Execution Plan enhancements in SSMS 18.0
A new SQL Execution Plan viewer
Using the SQL Execution Plan for Query Performance Tuning
Saving your SQL Execution Plan
SQL Server执行计划概述
SQL Server执行计划类型
如何分析SQL执行计划图形组件
SQL Server执行计划操作员–第1部分
SQL Server执行计划操作员–第2部分
SQL Server执行计划操作员–第3部分
SQL Server执行计划操作员–第4部分
SSMS 18.0中SQL执行计划增强功能
新SQL执行计划查看器
使用SQL执行计划进行查询性能调整
保存您SQL执行计划

常见问题 (FAQs)

Should we create any index suggested by the SQL Execution Plan?

我们是否应该创建SQL执行计划建议的任何索引?

Automatically? No. you have to look at the Impact first.
Also, you have to test it and make sure it will enhance the performance of your query.

自动吗? 否。您必须先看一下Impact。
另外,您必须对其进行测试,并确保它可以增强查询的性能。

Should we concentrate on the arrow thickness in all cases?

在所有情况下,我们都应该专注于箭头的厚度吗?

You need to make sure that the arrow is thick at the beginning and getting thinner after that. Such as returning 2 rows after scanning thousands of records.

您需要确保箭头的开头很粗,之后又变细。 如扫描数千条记录后返回2行。

Can the Estimated SQL Execution Plan result be trusted?

可以估计SQL执行计划的结果吗?

This depends on the statistics. If it is updated the results should be the same. You need the Estimated SQL Execution Plan in case the query will take long time to execute and you need to troubleshoot it.

这取决于统计数据。 如果更新,结果应相同。 您需要估算SQL执行计划,以防查询将花费很长时间执行并且需要对它进行故障排除。

翻译自: https://www.sqlshack.com/how-to-analyze-sql-execution-plan-graphical-components/

sql执行组件是灰色的

sql执行组件是灰色的_如何分析SQL执行计划图形组件相关推荐

  1. vue 组件以字符串插入_今日分享:vue3多层嵌套组件如何访问到最外层组件的数据?...

    我们都知道在vue中父组件向子组件传参需要在组件使用的位置使用属性绑定的方式,然后在子组件中通过props接收父组件中传递过来的数据,如果涉及到多层组件嵌套我们需要涉及到好多次属性绑定和好多次prop ...

  2. sql 查询本月请假的人数_温故而知新---学习SQL练习作业

    在看过<SQL基础教程>(作者:MICK)后,陆续面试发现自己的实操确实差很多,又重新学习SQL知识,听了猴子老师新的知乎LIVE,发现这种新的SQL学习方式真好,知识点写的很清楚,也更容 ...

  3. 在sql server 发生未指定的错误_一条sql查询是怎么执行的?

    作为一个资深CRUD boy,对于mysql想必都比较熟悉.但很多人估计和我一样对于一条简单的sql语句可以熟练的使用,但要问起里面怎么执行的,可能大部分分人就懵逼了. 因此本文就就将分析一下一条基本 ...

  4. sql查询非11位非数字_非生产环境SQL查询性能调优技巧

    sql查询非11位非数字 It is a common misconception that you need real production data, or production like dat ...

  5. sql优化的方法及思路_合理的sql优化思路--如何缩短SQL调优时间?

    概述 当生产环境发生故障或者系统特别慢的时候,这时候你从awr报告拿到有问题的sql,但是优化的时候却优化了很久还没解决,这时候在领导或者客户面前就不太好了...那么我们怎么去缩短sql调优的时间,一 ...

  6. sql查询去除视图重复项_如何使用SQL查询视图,Postico使用技巧分享

    Postico凭借着简单易用的操作界面深受专业人员和新手的喜爱,小编也整理一点小技巧分享给大家,通过一次编辑多行节省时间,是你工作的好帮手,快来一起看看吧~ 如何使用SQL查询视图,Postico使用 ...

  7. sql 如何设置行级锁_如何使用SQL Server 2016行级安全性过滤和阻止数据访问

    sql 如何设置行级锁 SQL Server 2016 came with many new features and enhancements for existing ones, that con ...

  8. python组件的react实现_【React源码解读】- 组件的实现

    前言 react使用也有一段时间了,大家对这个框架褒奖有加,但是它究竟好在哪里呢? 让我们结合它的源码,探究一二!(当前源码为react16,读者要对react有一定的了解) 回到最初 根据react ...

  9. python执行shell脚本报错_在python中执行shell命令:字符串错误

    我在Windows命令行参考中的以下内容似乎相关: * Using multiple commands You can use multiple commands separated by the c ...

最新文章

  1. 复数矩阵QR分解算法的C++实现
  2. 基本电子电路系列——MOS管
  3. 0218互联网新闻 | 《流浪地球》IMAX中国票房破3亿;苹果发力智能家居
  4. leetcode 189. 旋转数组
  5. Android之Window与WindowManager
  6. java 注解scheduler_使用spring的@Scheduled注解执行定时任务,启动项目不输出警告
  7. 英语口语 Week14 Monday
  8. oracle存储过程 --1
  9. 51CTO大数据学习006--集合
  10. RequestsLibrary库入门介绍
  11. WeX5 - AJAX跨域调用相关知识-CORS和JSONP
  12. 雷达信号处理基础ppt
  13. 远程控制,从个人便捷走向企业安全
  14. hodj 1008 Elevator (模拟题)
  15. 感性负载,容性负载,阻性负载
  16. Cisco Packet Tracer 8.0 发布,百度网盘下载
  17. 耳麦没声音,耳麦不能说话
  18. MsCOCO数据集标注详解
  19. 单片机c语言数码管程序,51单片机C语言程序(三)数码管
  20. js的初识及数据类型简介

热门文章

  1. 新编计算机英语,新编计算机英语教程
  2. JPA学习笔记二——Hello World
  3. 20172327 2018-2019-1 《程序设计与数据结构》第五周学习总结
  4. VS2010上连接SQLite数据库
  5. vs2015中安装EntityFramework
  6. 使用 XML 维护 Selenium 自动化测试脚本 ZT
  7. 001 - JavaScript Array String
  8. 【零基础学Java】—初识Java(一)
  9. 定时休眠 linux,linux系统编程手册 定时器和休眠
  10. 固收基金可以长期持有吗?