How to tune query performance with execution plans

by Feb 7, 2020

To execute queries, the database engine of SQL Server analyzes the statement to find the most efficient way to access the required data. The query optimizer handles this analysis. The input to the query optimizer comprises the query, the database schema (that is, the table and index definitions), and the database statistics. The output of the query optimizer is a query execution plan, sometimes referred to as a query plan or just an execution plan. A query execution plan is a definition of the sequence in which the database engine accesses the source tables and the methods used to extract data from each table.

The queries or batches do not execute when generating estimated execution plans. An estimated execution plan does not contain any runtime information, such as actual resource usage metrics or runtime warnings. Instead, the estimated execution plan displays the query execution plan that the database engine would most likely use if the database engine were to execute the queries. The estimated execution plan displays the estimated rows flowing through the several operators in the plan.

We generate actual execution plans after the queries or batches execute. An actual execution plan contains runtime information, such as the actual number of rows, resource usage metrics and runtime warnings.

An execution plan diagram displays the data retrieval methods chosen by the query optimizer. Execution plan diagrams represent the execution cost of specific statements and queries in SQL Server using icons rather than a tabular representation. This graphical approach is useful for understanding the performance characteristics of a query.

Using execution plans to tune the performance of queries for SQL Server can be a great starting point to help database applications run optimally. The execution plans have been around for some time now. Microsoft has improved the interface and added extra tools with every release.

Watch the 1-hour Geek Sync webcast ”Performance Tuning with Execution Plans by Thomas LeBlanc to learn about the history of execution plans. The progression will be to scans and seeks while dipping into loops and lookups. These are the basic skills needed to use execution plans. The session will conclude with the new features released with SQL Server 2016 and 2017.

The presenter, Thomas LeBlanc, is a Microsoft Data Platform MVP. He is a Data Warehouse and Business Intelligence Architect in Baton Rouge, Louisiana. Thomas uses his decades of experience in IT to help develop an OLAP database for end-to-end dimensional data marts with SSIS, SSAS, Power BI, and Excel. He also assists with OLTP systems designing and tuning normalized databases for high-performing T-SQL. Thomas presented at PASS Summit (2011 to 2017), VSLive (2018), Live! 360 (2015 to 2017), IT/Dev Connections (2015 and 2017) and SQLSaturday events (2011 to 2018).

community.idera.com/…/preview-_2D00_-webcast-_2D00_-Geek-Sync-_2D00_-Performance-Tuning-with-Execution-Plans.mp4

Click here to watch the entire Geek Sync webcast.

Click here to view the presentation slides.

SQL Diagnostic Manager for SQL Server

SQL Diagnostic Manager for SQL Server helps database administrators to find and fix SQL Server performance problems in physical, virtual, and cloud environments. Unlike its competition, it provides effective scalability, advanced query analysis and optimization, prescriptive analysis with corrective SQL scripts, powerful automated alert responses, broad PowerShell integration, complete customization, and extensive support for current and legacy SQL Server and Windows.

With SQL Diagnostic Manager for SQL Server, execution plans help to assess how queries perform and where to improve the code. The execution plan diagram displays the estimated or actual query execution plan. The diagram shows the tree of operations that make up a query. This tree shows individual operation nodes and the pertaining graphical execution plan icon, along with basic information such as operator name and operation percentage of the total cost. The execution plan also shows the referenced tables and columns to understand where a potential index change may improve performance.

For SQL Diagnostic Manager for SQL Server, view the product pages, download a free, fully functional, 14-day trial, request a product demonstration, and request a price quotation.