In the SQL Server query execution plans – Basics, we described the query execution plans in SQL Server and why they are important for performance analysis. In this article, we will focus on the methods for opening the plans, both actual and estimated ones
在“ SQL Server查询执行计划-基础知识”中 ,我们描述了SQL Server中的查询执行计划以及为什么它们对性能分析很重要。 在本文中,我们将重点介绍开放计划的方法,包括实际的和估计的方法。
If you look at the Query item in the SQL Server Management Studio menu, you’ll see two options related to query plans – Display Estimated Execution plan and Include Actual Execution plan
如果您查看SQL Server Management Studio菜单中的“ 查询”项,您将看到与查询计划相关的两个选项-“ 显示估计的执行计划”和“ 包括实际的执行计划”
An estimated execution plan is a SQL Server query plan that is generated without actually running the query (or stored procedure) the plan is created for. It’s based on estimation of expected behavior. It’s useful for analyzing how a query would behave, without actually running it. This is very useful for testing purposes in environments where performance should not be affected by running actual code (e.g. running a SELECT statement with complex joins against huge tables), or when running code is not possible due to data changes it makes (e.g. executing an UPDATE). Its downside is that it might be inaccurate in some scenarios
估计执行计划是一种SQL Server查询计划,该计划是在不实际运行为其创建查询的查询(或存储过程)的情况下生成的。 它基于对预期行为的估计。 这对于分析查询的行为很有用,而无需实际运行它。 这对于在以下环境中进行测试的目的非常有用:在这些环境中,运行实际代码不会影响性能(例如,对大型表运行带有复杂联接的SELECT语句),或者由于数据更改而无法运行代码(例如,执行更新)。 它的缺点是在某些情况下可能不准确
An actual execution plan is the SQL Server query plan that is generated after a query was executed. It’s more reliable, as it’s based on the actual execution, not estimates. It also provides more information and statistics, therefore it’s much useful in troubleshooting
实际的执行计划是在执行查询后生成SQL Server查询计划。 它更可靠,因为它基于实际执行,而不是估计。 它还提供更多的信息和统计信息,因此在故障排除中非常有用
There are several methods available for viewing a query plan in SQL Server
有几种方法可用于查看SQL Server中的查询计划
使用ApexSQL计划查看实际执行计划 (View Actual execution plan using ApexSQL Plan)
The Actual execution plan option is available in the in the Home tab of ApexSQL Plan
ApexSQL Plan的“主页”选项卡中的“ 实际执行计划”选项可用
- Query in ApexSQL Plan查询
- Actual execution plan option实际执行计划选项
SELECT *
FROM person.PersonPhone
WHERE PhoneNumber LIKE '%697%'
If multiple SQL queries are e