sql server query plan


Add the following sentence before your execution sql statement to list the corresponding execution plan


set statistics profile on 


  Please respect knowledge and originality. For more information, please refer to http://www.cezuwang.com/listFilm?page=1&areaId=906&filmTypeId=1 . Brief description of the execution plan [Rows]: Indicates that in an execution step, the number of records. (Real data, unexpected) [Executes]: Indicates the number of times a certain execution step is executed. (Real data, not expected) [Stmt Text]: Indicates the description of the steps to be executed. [EstimateRows]: Indicates how many rows of data are expected to be returned. In this [Execution Process Table], for optimizing the query, I think the first three columns are more important. For the first two columns, I also explained above, and the meaning is very clear. The numbers in the first two columns also roughly reflect the cost of those steps, which should be kept in mind for slower queries. [Stmt Text] will tell you what each step does. For this kind of table, what it wants to express is actually a kind of tree information (one line represents a node in the graphical mode), so I recommend reading them from the innermost layer. As an example, let me explain the execution process that this table expresses. Line 5: [Clustered Index Seek(OBJECT:([MyNorthwind].[dbo].[Customers].[PK_Customers]), SEEK:([MyNorthwind].[dbo].[Customers].[CustomerID]=[MyNorthwind] ].[dbo].[Orders].[CustomerID]) ORDERED FORWARD)], which means that SQL Server is doing a Seek operation on the table Customers, and it is in accordance with the [Clustered Index Seek] method, and the corresponding index is [PK_Customers] ], the value of seek comes from [Orders].[CustomerID]  












Line 4: [Clustered Index Scan(OBJECT:([MyNorthwind].[dbo].[Orders].[PK_Orders]), WHERE:([MyNorthwind].[dbo].[Orders].[OrderDate]>=' 2010-12-01 00:00:00.000' AND [MyNorthwind].[dbo].[Orders].[OrderDate]<'2011-12-01 00:00:00.000'))], which means that SQL Server In the Scan operation on the table Customers, that is: the worst way of [table scan], the reason is that there is no index on the OrderDate column, so this is the only way.

Line 3: [Nested Loops(Left Outer Join, OUTER REFERENCES:([MyNorthwind].[dbo].[Orders].[CustomerID]))], which means that SQL Server generates lines 5 and 4 The data of [Nested Loops] is used to join, in which the Outer table is Orders, and the matching operation to be joined is also pointed out in line 5.

Line 2: [Compute Scalar(DEFINE:([Expr1006]=isnull([MyNorthwind].[dbo].[Customers].[CustomerName],N'')))], which means to execute an isnull( ) function call. For specific reasons, please refer to the view definition code given in the previous part of this article.

Line 1: [SELECT [v].[OrderID],[v].[CustomerID],[v].[CustomerName],[v].[OrderDate],[v].[SumMoney],[v]. [Finished] FROM [OrdersView] [v] WHERE [v].[OrderDate]>=@1 AND [v].[OrderDate]<@2], usually the first line is the entire query, indicating its return value.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327014726&siteId=291194637