Learn how to read SQL Server execution plan

Original link: http://www.cnblogs.com/TSPWater/p/7929325.html

Data Query section

1,  see the implementation plan, there are two ways to sql statement by Ctrl + L, or press Ctrl + M to open the window displays the execution plan for each execution sql will show the corresponding implementation plan

2,  the graph execution plan is from right to left to see

3,  SQL Server there are several ways to find data record

[Table Scan] table scan (slowest), row of table records check

[Clustered Index Scan] aggregation index scan (slow), according to the progressive accumulation index records check

[Index Scan] index scan (normal), filtered off and the index portion of the data is performed line by line

[Index Seek] index lookup (faster), and then remove the recording location according to the location index location history

[Clustered Index Seek] Clustered Index Seek (fastest), to obtain records directly from the clustered index

(If some sql execution is slow can look at the execution plan contains too much "Scan" operation, if there can be considered for these fields indexed, indexing is often establish remember not to update on the field, each update will lead to operating rebuild the index will also affect performance, such identification 0 or 1 state field because most of the data are the same index also no effect)

(Index to two kinds, a clustered index 1, index 2 non-aggregated, clustered index each table can have only one, non-clustered index of a table can have multiple primary keys clustered index Id is a typical, sequential aggregation index spelling dictionary lookup arrangement similar to a, b, c ...... dictionary, and text in the same order, the arrangement and content of non-clustered index non-sequential, Similarly dictionary lookup radical, a radical with 'Ma' of one of the possible characters at a 10 page 100)

4、  

⑴ no primary key table query [Table Scan]

⑵ table has a primary key query [a Clustered Index Scan]

⑶ table query establish non-clustered index [index scan + bookmark lookup]

Bookmark Lookup: Locate the line that asked for by the non-clustered index, but the index does not contain the columns displayed, and therefore also additional to the basic columns found in the table, so to be key lookup, if the base table in the heap is Key Lookup Find RID will become, both collectively look to find a bookmark.

⑷ establish non-clustered index and the other displaying columns added to the index [index lookup]

⑸ establish non-clustered index and the other displaying columns added to the index and the clustered index column as the condition [Clustered Index Seek]

Reproduced in: https: //www.cnblogs.com/TSPWater/p/7929325.html

Guess you like

Origin blog.csdn.net/weixin_30642561/article/details/95302690