How do I obtain a Query Execution Plan in SQL Server?

前端 未结 12 1930
不知归路
不知归路 2020-11-21 04:17

In Microsoft SQL Server how can I get a query execution plan for a query / stored procedure?

12条回答
  •  心在旅途
    2020-11-21 05:07

    Beside the methods described in previous answers, you can also use a free execution plan viewer and query optimization tool ApexSQL Plan (which I’ve recently bumped into).

    You can install and integrate ApexSQL Plan into SQL Server Management Studio, so execution plans can be viewed from SSMS directly.

    Viewing Estimated execution plans in ApexSQL Plan

    1. Click the New Query button in SSMS and paste the query text in the query text window. Right click and select the “Display Estimated Execution Plan” option from the context menu.

    1. The execution plan diagrams will be shown the Execution Plan tab in the results section. Next right-click the execution plan and in the context menu select the “Open in ApexSQL Plan” option.

    1. The Estimated execution plan will be opened in ApexSQL Plan and it can be analyzed for query optimization.

    Viewing Actual execution plans in ApexSQL Plan

    To view the Actual execution plan of a query, continue from the 2nd step mentioned previously, but now, once the Estimated plan is shown, click the “Actual” button from the main ribbon bar in ApexSQL Plan.

    Once the “Actual” button is clicked, the Actual execution plan will be shown with detailed preview of the cost parameters along with other execution plan data.

    More information about viewing execution plans can be found by following this link.

提交回复
热议问题