时间:2021-07-01 10:21:17 帮助过:2人阅读
1 <?xml version="1.0"?> 2 <ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.1" Build="10.0.1600.22"> 3 <BatchSequence> 4 <Batch> 5 <Statements> 6 <StmtSimple StatementText="SELECT c.* FROM dbo.Category AS c 7 JOIN dbo.Product AS p 8 ON c.CategoryId=p.CategoryId 9 WHERE c.CategoryId=23794" StatementId="1" StatementCompId="1" StatementType="SELECT" StatementSubTreeCost="1.33278" StatementEstRows="1.03803" StatementOptmLevel="FULL" QueryHash="0xB10B821B9B5E6396" QueryPlanHash="0x8C7B3B1660E28D16"> 10 <StatementSetOptions QUOTED_IDENTIFIER="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" NUMERIC_ROUNDABORT="false" /> 11 <QueryPlan CachedPlanSize="16" CompileTime="2" CompileCPU="2" CompileMemory="168"> 12 <MissingIndexes> 13 <MissingIndexGroup Impact="99.4633"> 14 <MissingIndex Database="[MYPETSHOP]" Schema="[dbo]" Table="[Product]"> 15 <ColumnGroup Usage="EQUALITY"> 16 <Column Name="[CategoryId]" ColumnId="2" /> 17 </ColumnGroup> 18 </MissingIndex> 19 </MissingIndexGroup> 20 <MissingIndexGroup Impact="99.4636"> 21 <MissingIndex Database="[MYPETSHOP]" Schema="[dbo]" Table="[Product]"> 22 <ColumnGroup Usage="EQUALITY"> 23 <Column Name="[CategoryId]" ColumnId="2" /> 24 </ColumnGroup> 25 </MissingIndex> 26 </MissingIndexGroup> 27 </MissingIndexes> 28 <RelOp NodeId="0" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="1.03803" EstimateIO="0" EstimateCPU="4.33898e-006" AvgRowSize="97" EstimatedTotalSubtreeCost="1.33278" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"> 29 <OutputList> 30 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="CategoryId" /> 31 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="Name" /> 32 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="Image" /> 33 </OutputList> 34 <NestedLoops Optimized="0"> 35 <RelOp NodeId="1" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="97" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="1.00001e+006" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"> 36 <OutputList> 37 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="CategoryId" /> 38 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="Name" /> 39 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="Image" /> 40 </OutputList> 41 <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0"> 42 <DefinedValues> 43 <DefinedValue> 44 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="CategoryId" /> 45 </DefinedValue> 46 <DefinedValue> 47 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="Name" /> 48 </DefinedValue> 49 <DefinedValue> 50 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="Image" /> 51 </DefinedValue> 52 </DefinedValues> 53 <Object Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Index="[PK_Category]" Alias="[c]" IndexKind="Clustered" /> 54 <SeekPredicates> 55 <SeekPredicateNew> 56 <SeekKeys> 57 <Prefix ScanType="EQ"> 58 <RangeColumns> 59 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Category]" Alias="[c]" Column="CategoryId" /> 60 </RangeColumns> 61 <RangeExpressions> 62 <ScalarOperator ScalarString="(23794)"> 63 <Const ConstValue="(23794)" /> 64 </ScalarOperator> 65 </RangeExpressions> 66 </Prefix> 67 </SeekKeys> 68 </SeekPredicateNew> 69 </SeekPredicates> 70 </IndexScan> 71 </RelOp> 72 <RelOp NodeId="2" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="1.03803" EstimateIO="1.18831" EstimateCPU="0.0983419" AvgRowSize="11" EstimatedTotalSubtreeCost="1.28665" TableCardinality="89259" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"> 73 <OutputList /> 74 <IndexScan Ordered="0" ForcedIndex="0" NoExpandHint="0"> 75 <DefinedValues /> 76 <Object Database="[MYPETSHOP]" Schema="[dbo]" Table="[Product]" Index="[PK_Product]" Alias="[p]" IndexKind="Clustered" /> 77 <Predicate> 78 <ScalarOperator ScalarString="[MYPETSHOP].[dbo].[Product].[CategoryId] as [p].[CategoryId]=(23794)"> 79 <Compare CompareOp="EQ"> 80 <ScalarOperator> 81 <Identifier> 82 <ColumnReference Database="[MYPETSHOP]" Schema="[dbo]" Table="[Product]" Alias="[p]" Column="CategoryId" /> 83 </Identifier> 84 </ScalarOperator> 85 <ScalarOperator> 86 <Const ConstValue="(23794)" /> 87 </ScalarOperator> 88 </Compare> 89 </ScalarOperator> 90 </Predicate> 91 </IndexScan> 92 </RelOp> 93 </NestedLoops> 94 </RelOp> 95 </QueryPlan> 96 </StmtSimple> 97 </Statements> 98 </Batch> 99 </BatchSequence> 100 </ShowPlanXML>
好了,到现在你应该认识到重新生成执行计划是不容易的。。。下一篇我们讨论讨论重用,重编译,重新生成等相关情况。
sqlserver的执行计划
标签: