Execution plan analysis

  • I am doing some execution plan analysis. I have found that some plans do not contain: @StatementOptmEarlyAbortReason.

    I am looking for values: GoodEnoughPlanFound, TimeOut, MemoryLimitExceeded.

    Can anyone explain this / provide logic?

  • scott.laird (8/25/2015)


    I am doing some execution plan analysis. I have found that some plans do not contain: @StatementOptmEarlyAbortReason.

    I am looking for values: GoodEnoughPlanFound, TimeOut, MemoryLimitExceeded.

    Can anyone explain this / provide logic?

    One possibility might be that the queries involved generated a "trivial plan", for which there can be no optimization. Perhaps in some cases, an ideal plan is found quickly because it's a query for which the ideal plan is truly easy to get to and either there aren't any alternatives, or the obvious alternatives have obviously high costs and thus the optimizer concludes within it's time budget that is has the best possible plan?

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Can you post one or two samples of the plans that don't have that property?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • This in NOT my code...this is NOT my company's code...it is code from a third party vendor.

    StatementOptmLevel="FULL"

    <ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.1.1" Build="10.0.6000.29">

    <BatchSequence>

    <Batch>

    <Statements>

    <StmtSimple StatementText="(@P0 varchar(8000),@P1 datetime,@P2 varchar(8000),@P3 datetime) SELECT wcv.cnsmr_id as entityId FROM (SELECT DISTINCT c.cnsmr_id FROM cnsmr c INNER JOIN cnsmr_addrss cad on cad.cnsmr_id=c.cnsmr_id INNER JOIN cnsmr_tag ct ON c.cnsmr_id = ct.cnsmr_id AND ct.cnsmr_tag_sft_delete_flg = 'N' INNER JOIN tag ctt on ctt.tag_id = ct.tag_id WHERE cad.cnsmr_addrss_st_txt in ('NY','MA') and ctt.tag_shrt_nm = '10' ) wcv INNER JOIN cnsmr_Wrk_actn cwa ON wcv.cnsmr_id=cwa.cnsmr_id AND cwa.cnsmr_lck_flg='N' AND cwa.cnsmr_is_hld_flg='N' INNER JOIN cnsmr c on cwa.cnsmr_id = c.cnsmr_id INNER JOIN wrkgrp_scan_lst wc on wc.wrkgrp_id = c.wrkgrp_id AND wc.wrkgrp_scan_lst_id = @P0 WHERE (cwa.cnsmr_wrkd_lst_dt < @P1 OR cwa.cnsmr_wrkd_lst_dt IS NULL) AND c.cnsmr_id NOT IN ( SELECT dc.cnsmr_id FROM dfrrd_cnsmr dc WHERE dc.dfrrd_cnsmr_entty_assctn_cd = (SELECT entty_assctn_cd FROM Ref_entty_assctn_cd WHERE entty_assctn_val_txt = 'WORKCHAIN') AND dc.dfrrd_cnsmr_entty_id = @P2 AND dc.cnsmr_dfrrd_dttm > @P3) ORDER BY cwa.cnsmr_cntct_nxt_dt ASC " StatementId="1" StatementCompId="1" StatementType="SELECT" StatementSubTreeCost="65.9772" StatementEstRows="8408.83" StatementOptmLevel="FULL" QueryHash="0xD43726B9C2BFA5B5" QueryPlanHash="0x44D7AEAFCCFB2279">

    <StatementSetOptions QUOTED_IDENTIFIER="true" ARITHABORT="false" CONCAT_NULL_YIELDS_NULL="true" ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" NUMERIC_ROUNDABORT="false" />

    <QueryPlan CachedPlanSize="96" CompileTime="362" CompileCPU="335" CompileMemory="3728">

    <RelOp NodeId="0" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="8408.83" EstimateIO="0.0112613" EstimateCPU="0.393029" AvgRowSize="23" EstimatedTotalSubtreeCost="65.9772" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_cntct_nxt_dt" />

    </OutputList>

    <MemoryFractions Input="0.960784" Output="1" />

    <Sort Distinct="0">

    <OrderBy>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_cntct_nxt_dt" />

    </OrderByColumn>

    </OrderBy>

    <RelOp NodeId="1" PhysicalOp="Merge Join" LogicalOp="Left Anti Semi Join" EstimateRows="8408.83" EstimateIO="0" EstimateCPU="0.00644508" AvgRowSize="23" EstimatedTotalSubtreeCost="65.5729" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_cntct_nxt_dt" />

    </OutputList>

    <Merge ManyToMany="0">

    <InnerSideJoinColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="cnsmr_id" />

    </InnerSideJoinColumns>

    <OuterSideJoinColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </OuterSideJoinColumns>

    <Residual>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[cnsmr].[cnsmr_id] as [c].[cnsmr_id]=[crs5_oltp].[dbo].[dfrrd_cnsmr].[cnsmr_id] as [dc].[cnsmr_id]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Residual>

    <RelOp NodeId="2" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="8407.01" EstimateIO="0" EstimateCPU="0.000392014" AvgRowSize="31" EstimatedTotalSubtreeCost="65.5561" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_cntct_nxt_dt" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </OutputList>

    <NestedLoops Optimized="0" WithOrderedPrefetch="1">

    <OuterReferences>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    <ColumnReference Column="Expr1030" />

    </OuterReferences>

    <RelOp NodeId="5" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="93.7832" EstimateIO="0.0112613" EstimateCPU="0.00105848" AvgRowSize="23" EstimatedTotalSubtreeCost="65.2512" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </OutputList>

    <MemoryFractions Input="0.000731395" Output="0.0392157" />

    <Sort Distinct="0">

    <OrderBy>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </OrderByColumn>

    </OrderBy>

    <RelOp NodeId="6" PhysicalOp="Hash Match" LogicalOp="Inner Join" EstimateRows="93.7832" EstimateIO="0" EstimateCPU="0.534154" AvgRowSize="23" EstimatedTotalSubtreeCost="65.2388" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </OutputList>

    <MemoryFractions Input="0.0358628" Output="0.0504663" />

    <Hash>

    <DefinedValues />

    <HashKeysBuild>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </HashKeysBuild>

    <HashKeysProbe>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </HashKeysProbe>

    <ProbeResidual>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[cnsmr].[cnsmr_id] as [c].[cnsmr_id]=[crs5_oltp].[dbo].[cnsmr].[cnsmr_id] as [c].[cnsmr_id]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ProbeResidual>

    <RelOp NodeId="7" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="9751.98" EstimateIO="0" EstimateCPU="0.0407633" AvgRowSize="15" EstimatedTotalSubtreeCost="0.103241" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </OutputList>

    <NestedLoops Optimized="0">

    <OuterReferences>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[wrkgrp_scan_lst]" Alias="[wc]" Column="wrkgrp_id" />

    </OuterReferences>

    <RelOp NodeId="8" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="15" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="26486" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[wrkgrp_scan_lst]" Alias="[wc]" Column="wrkgrp_id" />

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[wrkgrp_scan_lst]" Alias="[wc]" Column="wrkgrp_id" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[wrkgrp_scan_lst]" Index="[PK__wrkgrp_scan_lst__46A92998]" Alias="[wc]" IndexKind="Clustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[wrkgrp_scan_lst]" Alias="[wc]" Column="wrkgrp_scan_lst_id" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[@P0],0)">

    <Identifier>

    <ColumnReference Column="ConstExpr1020">

    <ScalarOperator>

    <Convert DataType="int" Style="0" Implicit="1">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@P0" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    <RelOp NodeId="9" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="9751.98" EstimateIO="0.0483102" EstimateCPU="0.0108842" AvgRowSize="15" EstimatedTotalSubtreeCost="0.0591944" TableCardinality="5.63665e+006" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Index="[IX_cnsmr_20130225]" Alias="[c]" TableReferenceId="2" IndexKind="NonClustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="wrkgrp_id" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[wrkgrp_scan_lst].[wrkgrp_id] as [wc].[wrkgrp_id]">

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[wrkgrp_scan_lst]" Alias="[wc]" Column="wrkgrp_id" />

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp NodeId="11" PhysicalOp="Hash Match" LogicalOp="Right Semi Join" EstimateRows="82123.8" EstimateIO="0" EstimateCPU="38.1724" AvgRowSize="15" EstimatedTotalSubtreeCost="64.5932" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </OutputList>

    <MemoryFractions Input="0.674246" Output="0.948802" />

    <Hash>

    <DefinedValues />

    <HashKeysBuild>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="cnsmr_id" />

    </HashKeysBuild>

    <HashKeysProbe>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </HashKeysProbe>

    <ProbeResidual>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[cnsmr].[cnsmr_id] as [c].[cnsmr_id]=[crs5_oltp].[dbo].[cnsmr_Tag].[cnsmr_id] as [ct].[cnsmr_id]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ProbeResidual>

    <RelOp NodeId="12" PhysicalOp="Hash Match" LogicalOp="Inner Join" EstimateRows="73749.5" EstimateIO="0" EstimateCPU="4.69433" AvgRowSize="15" EstimatedTotalSubtreeCost="7.40759" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="cnsmr_id" />

    </OutputList>

    <MemoryFractions Input="0.964137" Output="0.289891" />

    <Hash>

    <DefinedValues />

    <HashKeysBuild>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="cnsmr_id" />

    </HashKeysBuild>

    <HashKeysProbe>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_addrss]" Alias="[cad]" Column="cnsmr_id" />

    </HashKeysProbe>

    <ProbeResidual>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[cnsmr_addrss].[cnsmr_id] as [cad].[cnsmr_id]=[crs5_oltp].[dbo].[cnsmr_Tag].[cnsmr_id] as [ct].[cnsmr_id]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_addrss]" Alias="[cad]" Column="cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </ProbeResidual>

    <RelOp NodeId="13" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="67507.4" EstimateIO="0" EstimateCPU="0.282181" AvgRowSize="15" EstimatedTotalSubtreeCost="0.604486" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="cnsmr_id" />

    </OutputList>

    <NestedLoops Optimized="0">

    <OuterReferences>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[tag]" Alias="[ctt]" Column="tag_id" />

    </OuterReferences>

    <RelOp NodeId="14" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="15" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="1569" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[tag]" Alias="[ctt]" Column="tag_id" />

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[tag]" Alias="[ctt]" Column="tag_id" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[tag]" Index="[IX_tag_20130919]" Alias="[ctt]" IndexKind="NonClustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[tag]" Alias="[ctt]" Column="tag_shrt_nm" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="'10'">

    <Const ConstValue="'10'" />

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    <RelOp NodeId="15" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="67507.4" EstimateIO="0.244606" EstimateCPU="0.0744152" AvgRowSize="15" EstimatedTotalSubtreeCost="0.319022" TableCardinality="5.9935e+007" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="cnsmr_id" />

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="cnsmr_id" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Index="[IX_cnsmr_Tag_20150123]" Alias="[ct]" IndexKind="NonClustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="tag_id" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Tag]" Alias="[ct]" Column="cnsmr_tag_sft_delete_flg" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[tag].[tag_id] as [ctt].[tag_id]">

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[tag]" Alias="[ctt]" Column="tag_id" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="'N'">

    <Const ConstValue="'N'" />

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp NodeId="16" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="531585" EstimateIO="1.52387" EstimateCPU="0.584901" AvgRowSize="15" EstimatedTotalSubtreeCost="2.10877" TableCardinality="5.61986e+006" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_addrss]" Alias="[cad]" Column="cnsmr_id" />

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_addrss]" Alias="[cad]" Column="cnsmr_id" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_addrss]" Index="[IX_cnsmr_addrss_MiscInclude]" Alias="[cad]" IndexKind="NonClustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_addrss]" Alias="[cad]" Column="cnsmr_addrss_st_txt" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="'MA'">

    <Const ConstValue="'MA'" />

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_addrss]" Alias="[cad]" Column="cnsmr_addrss_st_txt" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="'NY'">

    <Const ConstValue="'NY'" />

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    </Hash>

    </RelOp>

    <RelOp NodeId="18" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="5.63665e+006" EstimateIO="12.8128" EstimateCPU="6.20047" AvgRowSize="15" EstimatedTotalSubtreeCost="19.0132" TableCardinality="5.63665e+006" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </OutputList>

    <IndexScan Ordered="0" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Index="[IX_cnsmr_20140415]" Alias="[c]" TableReferenceId="1" IndexKind="NonClustered" />

    </IndexScan>

    </RelOp>

    </Hash>

    </RelOp>

    </Hash>

    </RelOp>

    </Sort>

    </RelOp>

    <RelOp NodeId="25" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="23" EstimatedTotalSubtreeCost="0.304469" TableCardinality="5.63275e+006" Parallel="0" EstimateRebinds="92.7832" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_cntct_nxt_dt" />

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_cntct_nxt_dt" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Index="[IX_cnsmr_Wrk_actn_20140813_2]" Alias="[cwa]" IndexKind="NonClustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_id" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_lck_flg" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_is_hld_flg" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[cnsmr].[cnsmr_id] as [c].[cnsmr_id]">

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr]" Alias="[c]" Column="cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator ScalarString="'N'">

    <Const ConstValue="'N'" />

    </ScalarOperator>

    <ScalarOperator ScalarString="'N'">

    <Const ConstValue="'N'" />

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    <Predicate>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[cnsmr_Wrk_actn].[cnsmr_wrkd_lst_dt] as [cwa].[cnsmr_wrkd_lst_dt]<[@P1] OR [crs5_oltp].[dbo].[cnsmr_Wrk_actn].[cnsmr_wrkd_lst_dt] as [cwa].[cnsmr_wrkd_lst_dt] IS NULL">

    <Logical Operation="OR">

    <ScalarOperator>

    <Compare CompareOp="LT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_wrkd_lst_dt" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@P1" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="IS">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[cnsmr_Wrk_actn]" Alias="[cwa]" Column="cnsmr_wrkd_lst_dt" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp NodeId="26" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="1" EstimateIO="0" EstimateCPU="4.18e-006" AvgRowSize="15" EstimatedTotalSubtreeCost="0.0103518" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="cnsmr_id" />

    </OutputList>

    <NestedLoops Optimized="0">

    <OuterReferences>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_entty_assctn_cd" />

    </OuterReferences>

    <RelOp NodeId="27" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="4" EstimateIO="0" EstimateCPU="1.672e-005" AvgRowSize="33" EstimatedTotalSubtreeCost="0.00706052" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="cnsmr_id" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_entty_assctn_cd" />

    </OutputList>

    <NestedLoops Optimized="0">

    <OuterReferences>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_id" />

    </OuterReferences>

    <RelOp NodeId="28" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="4" EstimateIO="0.003125" EstimateCPU="0.0001614" AvgRowSize="23" EstimatedTotalSubtreeCost="0.0032864" TableCardinality="4" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_id" />

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="cnsmr_id" />

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_id" />

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="cnsmr_id" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Index="[dfrrd_cnsmr_ie1]" Alias="[dc]" IndexKind="NonClustered" />

    </IndexScan>

    </RelOp>

    <RelOp NodeId="30" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="25" EstimatedTotalSubtreeCost="0.0037574" TableCardinality="4" Parallel="0" EstimateRebinds="3" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_entty_assctn_cd" />

    </OutputList>

    <IndexScan Lookup="1" Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_entty_assctn_cd" />

    </DefinedValue>

    </DefinedValues>

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Index="[PK__dfrrd_cnsmr__52B0D213]" Alias="[dc]" TableReferenceId="-1" IndexKind="Clustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_id" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[dfrrd_cnsmr].[dfrrd_cnsmr_id] as [dc].[dfrrd_cnsmr_id]">

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_id" />

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    <Predicate>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[dfrrd_cnsmr].[dfrrd_cnsmr_entty_id] as [dc].[dfrrd_cnsmr_entty_id]=CONVERT_IMPLICIT(bigint,[@P2],0) AND [crs5_oltp].[dbo].[dfrrd_cnsmr].[cnsmr_dfrrd_dttm] as [dc].[cnsmr_dfrrd_dttm]>[@P3]">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_entty_id" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="ConstExpr1021">

    <ScalarOperator>

    <Convert DataType="bigint" Style="0" Implicit="1">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@P2" />

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </ColumnReference>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="GT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="cnsmr_dfrrd_dttm" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="@P3" />

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp NodeId="34" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="24" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="76" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList />

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" NoExpandHint="0">

    <DefinedValues />

    <Object Database="[crs5_oltp]" Schema="[dbo]" Table="[Ref_entty_assctn_cd]" Index="[PK__Ref_entty_assctn__4D01216C]" IndexKind="Clustered" />

    <SeekPredicates>

    <SeekPredicateNew>

    <SeekKeys>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[Ref_entty_assctn_cd]" Column="entty_assctn_cd" />

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[dfrrd_cnsmr].[dfrrd_cnsmr_entty_assctn_cd] as [dc].[dfrrd_cnsmr_entty_assctn_cd]">

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[dfrrd_cnsmr]" Alias="[dc]" Column="dfrrd_cnsmr_entty_assctn_cd" />

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekKeys>

    </SeekPredicateNew>

    </SeekPredicates>

    <Predicate>

    <ScalarOperator ScalarString="[crs5_oltp].[dbo].[Ref_entty_assctn_cd].[entty_assctn_val_txt]='WORKCHAIN'">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[crs5_oltp]" Schema="[dbo]" Table="[Ref_entty_assctn_cd]" Column="entty_assctn_val_txt" />

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'WORKCHAIN'" />

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </Merge>

    </RelOp>

    </Sort>

    </RelOp>

    <ParameterList>

    <ColumnReference Column="@P3" ParameterCompiledValue="'2015-08-26 08:48:37.247'" />

    <ColumnReference Column="@P2" ParameterCompiledValue="'22346'" />

    <ColumnReference Column="@P1" ParameterCompiledValue="'2015-08-26 00:00:00.000'" />

    <ColumnReference Column="@P0" ParameterCompiledValue="'22346'" />

    </ParameterList>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    </Batch>

    </BatchSequence>

    </ShowPlanXML>

  • I don't know why that property is sometimes missing from a plan. I'll see if I can find out.

    How are you capturing this query? Through SSMS? Querying the cache? Capturing it through trace or extended events. I'm just curious because that might be part of the equation.

    It's clearly not a trivial query and it's marked as FULL optimization.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • I am using SSMS.

    IF object_id('tempdb..#X') IS NOT NULL

    BEGIN

    DROP TABLE #X;

    END

    --create temp table

    CREATE TABLE #X (

    sql_handle varbinary(64),

    plan_handle varbinary(64),

    statement_start_offset int,

    statement_end_offset int,

    query_hash binary(8),

    query_plan_hash binary(8),

    creation_time datetime,

    last_execution_time datetime,

    execution_count int,

    AvgWorkerTime decimal(19,4),

    AvgLogicalReads decimal(19,4),

    SQL_Text varchar(max)

    );

    insert into #X (sql_handle,plan_handle,statement_start_offset,statement_end_offset,query_hash,query_plan_hash,creation_time,last_execution_time,execution_count,AvgWorkerTime,AvgLogicalReads)

    select TOP 300 sql_handle,plan_handle,statement_start_offset,statement_end_offset,query_hash,query_plan_hash,

    creation_time,last_execution_time,execution_count,

    CAST(total_worker_time as decimal(19,4)) / execution_count as AvgWorkerTime,

    CAST(total_logical_reads as decimal(19,4)) / execution_count as AvgLogicalReads

    FROM sys.dm_exec_query_stats

    ORDER BY AvgWorkerTime DESC;

    update #X SET SQL_Text = st.text

    FROM #X CROSS APPLY

    sys.dm_exec_sql_text(#X.sql_handle) st;

    WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p)

    select getdate() as DateTimeStamp,'???' as AbortReason,#X.creation_time,#X.last_execution_time,#X.execution_count,#X.AvgWorkerTime,#X.AvgLogicalReads,

    #X.SQL_Text,qp.query_plan

    FROM

    #X CROSS APPLY

    sys.dm_exec_query_plan(#X.plan_handle) AS qp

    WHERE NOT qp.query_plan.exist('//p:StmtSimple/@StatementOptmEarlyAbortReason[.="GoodEnoughPlanFound"]') = 1 and

    NOT qp.query_plan.exist('//p:StmtSimple/@StatementOptmLevel[.="TRIVIAL"]') = 1;

    DROP TABLE #X;

  • I have an explanation from Paul White, so I put a lot of faith in it.

    It was my understanding that when a plan was found that was adequate according to the optimizer, you would see the "Good Enough Plan Found" result. But, in fact, each of the different search levels within the optimizer has a set of triggers (and no, these aren't defined as such). When the triggers are met before the search is complete, you'll get "Good Enough Plan Found" as the reason for early termination because the process terminated early. But, if it completes the search and then decides that the plan is good enough, you won't see the "Good Enough Plan Found". This is because the search level completed and the plan found at the search level was determined to be adequate. You get timeouts when it runs through the iterations within the levels and runs out of iterations without finding a good plan.

    So, in short, effectively, if it says "Good Enough Plan Found" the optimizer was satisfied that it found a good enough plan. If it says nothing at all for the optimization level of FULL, then the optimizer was also satisfied that it found a good enough plan, but the process was not terminated early. Then there's timeout and the out of memory error as the other reasons for early termination.

    I hope that helps.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thank you for your time and effort.

    Scott

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply