Two ways to get execution plans in SQL Server _mssql

Source: Internet
Author: User
Tags switches
There are two ways to get the execution plan :
1, one is to open some switches in front of the instruction, let the execution plan information hit in the result set, this method is more suitable in a test environment for a single statement tuning.
The most common of these switches are
Copy Code code as follows:

SET Showplan_all on
SET Showplan_all on--(whether reuse an execution plan, Sqserverl does not feel that the index is missing), can only be seen in the output of XML
SET STATISTICS profile on

And if you use SSMs, you can use shortcut keys: ctrl+l lowercase L He will execute your statement and display the execution plan, but will not return the result set

2, another approach is to use event tracking in SQL Trace to track the execution plan of the statement.
Common events are: SHOWPLAN all, SHOWPLAN STATISTICS profile, SHOWPLAN XML STATISTICS profile
The advantage of this approach is that you can use direct tracking of the application's statement execution without having to open any switches.
The disadvantage is that he will catch all the statements. If SQL Server is busy, the output will be large and may affect performance, so use caution
--------------------------------------------------------------------------------
Most of the information collected by these two methods is the same. The way XML will return the results in the structure of XML, in SQL Trace, this result can graphically display the execution plan and its associated information.

A simpler statement for the execution plan, which might be a friendly way to export. But for the complex execution plan, if the graphical way to display, a screen is difficult to put down, each step of the statistical information to the mouse point to be displayed, the individual feel less than the text output format easy to read good.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.