FAIRYFAR-INTERNAL
 
  FAIRYFAR-INTERNAL  |  SITEMAP  |  ABOUT-ME  |  HOME  
orca执行计划解读

ORCA执行计划解读

ORCA优化器以XML格式输出执行计划信息。

可以在以下位置找到:

${BASE}/userdata/gbase/minidumps/

文件以执行时间为序。

示例:

snippet.sql
SELECT SUM(t1.a) FROM t11 t1 JOIN t11 t2 ON t1.a = t2.a WHERE t1.a > 4;

上述SQL对应执行计划如下“附录”所示。

其中,“Query”节点对应SQL原始执行计划,相当于ORCA的输入。“Plan”节点是ORCA优化后的执行计划。

“Plan”描述的是最终的执行计划,执行从内层向外层执行。可以与执行计划图对照。

附录

snippet.xml
<?xml version="1.0" encoding="UTF-8"?>
<dxl:DXLMessage xmlns:dxl="http://greenplum.com/dxl/2010/12/">
  <dxl:Thread Id="0">
    <dxl:OptimizerConfig>
      <dxl:EnumeratorConfig Id="0" PlanSamples="0" CostThreshold="0"/>
      <dxl:StatisticsConfig DampingFactorFilter="0.750000" DampingFactorJoin="0.010000" DampingFactorGroupBy="0.750000"/>
      <dxl:CTEConfig CTEInliningCutoff="0"/>
      <dxl:WindowOids RowNumber="3100" Rank="3101"/>
      <dxl:CostModelConfig CostModelType="1" SegmentsForCosting="1">
        <dxl:CostParams>
          <dxl:CostParam Name="NLJFactor" Value="1.000000" LowerBound="0.500000" UpperBound="1.500000"/>
        </dxl:CostParams>
      </dxl:CostModelConfig>
      <dxl:Hint MinNumOfPartsToRequireSortOnInsert="2147483647" JoinArityForAssociativityCommutativity="18" ArrayExpansionThreshold="100" JoinOrderDynamicProgThreshold="10" BroadcastThreshold="100000000" EnforceConstraintsOnDML="false"/>
      <dxl:TraceFlags Value="101000,101001,101002,101003,101004,101005,101006,101008,101009,101010,101012,102005,102006,102016,102024,102025,102056,102074,102107,102108,102109,102110,102111,102112,102115,102116,102117,102118,102119,102120,102128,102130,102131,102132,102133,102134,102135,102136,102140,102141,102142,102143,103001,103003,103027"/>
    </dxl:OptimizerConfig>
    <dxl:Metadata SystemIds="0.GPDB">
      <dxl:GPDBScalarOp Mdid="0.521.1.0" Name="&gt;" ComparisonType="GT" ReturnsNullOnNullInput="true">
        <dxl:LeftType Mdid="0.23.1.0"/>
        <dxl:RightType Mdid="0.23.1.0"/>
        <dxl:ResultType Mdid="0.16.1.0"/>
        <dxl:OpFunc Mdid="0.147.1.0"/>
      </dxl:GPDBScalarOp>
      <dxl:Type Mdid="0.16.1.0" Name="bool" IsRedistributable="true" IsHashable="true" IsComposite="false" IsFixedLength="true" Length="1" PassByValue="true">
        <dxl:EqualityOp Mdid="0.91.1.0"/>
        <dxl:InequalityOp Mdid="0.85.1.0"/>
        <dxl:LessThanOp Mdid="0.58.1.0"/>
        <dxl:LessThanEqualsOp Mdid="0.1694.1.0"/>
        <dxl:GreaterThanOp Mdid="0.59.1.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.1695.1.0"/>
        <dxl:ComparisonOp Mdid="0.1693.1.0"/>
        <dxl:ArrayType Mdid="0.1000.1.0"/>
        <dxl:MinAgg Mdid="0.0.0.0"/>
        <dxl:MaxAgg Mdid="0.0.0.0"/>
        <dxl:AvgAgg Mdid="0.0.0.0"/>
        <dxl:SumAgg Mdid="0.0.0.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
      <dxl:Type Mdid="0.20.1.0" Name="Int8" IsRedistributable="true" IsHashable="true" IsComposite="false" IsFixedLength="true" Length="8" PassByValue="true">
        <dxl:EqualityOp Mdid="0.410.1.0"/>
        <dxl:InequalityOp Mdid="0.411.1.0"/>
        <dxl:LessThanOp Mdid="0.412.1.0"/>
        <dxl:LessThanEqualsOp Mdid="0.414.1.0"/>
        <dxl:GreaterThanOp Mdid="0.413.1.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.415.1.0"/>
        <dxl:ComparisonOp Mdid="0.351.1.0"/>
        <dxl:ArrayType Mdid="0.1016.1.0"/>
        <dxl:MinAgg Mdid="0.2131.1.0"/>
        <dxl:MaxAgg Mdid="0.2115.1.0"/>
        <dxl:AvgAgg Mdid="0.2100.1.0"/>
        <dxl:SumAgg Mdid="0.2107.1.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
      <dxl:RelationStatistics Mdid="2.10006.1.0" Name="t11" Rows="1000.000000" EmptyRelation="false"/>
      <dxl:Type Mdid="0.23.1.0" Name="int4" IsRedistributable="true" IsHashable="true" IsComposite="false" IsFixedLength="true" Length="4" PassByValue="true">
        <dxl:EqualityOp Mdid="0.96.1.0"/>
        <dxl:InequalityOp Mdid="0.518.1.0"/>
        <dxl:LessThanOp Mdid="0.97.1.0"/>
        <dxl:LessThanEqualsOp Mdid="0.523.1.0"/>
        <dxl:GreaterThanOp Mdid="0.521.1.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.525.1.0"/>
        <dxl:ComparisonOp Mdid="0.351.1.0"/>
        <dxl:ArrayType Mdid="0.1007.1.0"/>
        <dxl:MinAgg Mdid="0.2132.1.0"/>
        <dxl:MaxAgg Mdid="0.2116.1.0"/>
        <dxl:AvgAgg Mdid="0.2101.1.0"/>
        <dxl:SumAgg Mdid="0.2108.1.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
      <dxl:Relation Mdid="0.10006.1.0" Name="t11" IsTemporary="false" HasOids="false" StorageType="AppendOnly, Column-oriented" DistributionPolicy="MasterOnly" NumberLeafPartitions="0">
        <dxl:Columns>
          <dxl:Column Name="a" Attno="1" Mdid="0.23.1.0" TypeModifier="0" Nullable="false" ColWidth="11">
            <dxl:DefaultValue/>
          </dxl:Column>
          <dxl:Column Name="b" Attno="2" Mdid="0.701.1.0" TypeModifier="0" Nullable="false" ColWidth="22">
            <dxl:DefaultValue/>
          </dxl:Column>
        </dxl:Columns>
        <dxl:IndexInfoList/>
        <dxl:Triggers/>
        <dxl:CheckConstraints/>
      </dxl:Relation>
      <dxl:ColumnStatistics Mdid="1.10006.1.0.0" Name="a" Width="4.000000" NullFreq="0.000000" NdvRemain="0.000000" FreqRemain="0.000000" ColStatsMissing="true"/>
      <dxl:Type Mdid="0.701.1.0" Name="double" IsRedistributable="true" IsHashable="true" IsComposite="false" IsFixedLength="true" Length="4" PassByValue="true">
        <dxl:EqualityOp Mdid="0.96.1.0"/>
        <dxl:InequalityOp Mdid="0.518.1.0"/>
        <dxl:LessThanOp Mdid="0.97.1.0"/>
        <dxl:LessThanEqualsOp Mdid="0.523.1.0"/>
        <dxl:GreaterThanOp Mdid="0.521.1.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.525.1.0"/>
        <dxl:ComparisonOp Mdid="0.351.1.0"/>
        <dxl:ArrayType Mdid="0.1007.1.0"/>
        <dxl:MinAgg Mdid="0.2132.1.0"/>
        <dxl:MaxAgg Mdid="0.2116.1.0"/>
        <dxl:AvgAgg Mdid="0.2108.1.0"/>
        <dxl:SumAgg Mdid="0.2101.1.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
      <dxl:GPDBAgg Mdid="0.2108.1.0" Name="sum" IsSplittable="true" HashAggCapable="true">
        <dxl:ResultType Mdid="0.20.1.0"/>
        <dxl:IntermediateResultType Mdid="0.20.1.0"/>
      </dxl:GPDBAgg>
      <dxl:MDCast Mdid="3.23.1.0;23.1.0" Name="int4" BinaryCoercible="true" SourceTypeId="0.23.1.0" DestinationTypeId="0.23.1.0" CastFuncId="0.0.0.0" CoercePathType="0"/>
      <dxl:GPDBScalarOp Mdid="0.96.1.0" Name="=" ComparisonType="Eq" ReturnsNullOnNullInput="true">
        <dxl:LeftType Mdid="0.23.1.0"/>
        <dxl:RightType Mdid="0.23.1.0"/>
        <dxl:ResultType Mdid="0.16.1.0"/>
        <dxl:OpFunc Mdid="0.65.1.0"/>
      </dxl:GPDBScalarOp>
    </dxl:Metadata>
    <dxl:Query>
      <dxl:OutputColumns>
        <dxl:Ident ColId="5" ColName="sum(t1.a)" TypeMdid="0.1700.1.0"/>
      </dxl:OutputColumns>
      <dxl:CTEList/>
      <dxl:LogicalGroupBy>
        <dxl:GroupingColumns/>
        <dxl:ProjList>
          <dxl:ProjElem ColId="5" Alias="sum(t1.a)">
            <dxl:AggFunc AggMdid="0.2108.1.0" AggDistinct="false" AggStage="Normal">
              <dxl:Ident ColId="1" ColName="a" TypeMdid="0.23.1.0"/>
            </dxl:AggFunc>
          </dxl:ProjElem>
        </dxl:ProjList>
        <dxl:LogicalJoin JoinType="Inner">
          <dxl:LogicalGet>
            <dxl:TableDescriptor Mdid="0.10006.1.0" TableName="t11">
              <dxl:Columns>
                <dxl:Column ColId="1" Attno="1" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0" ColWidth="11"/>
                <dxl:Column ColId="2" Attno="2" ColName="b" TypeMdid="0.701.1.0" TypeModifier="0" ColWidth="22"/>
              </dxl:Columns>
            </dxl:TableDescriptor>
          </dxl:LogicalGet>
          <dxl:LogicalGet>
            <dxl:TableDescriptor Mdid="0.10006.1.0" TableName="t11">
              <dxl:Columns>
                <dxl:Column ColId="3" Attno="1" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0" ColWidth="11"/>
                <dxl:Column ColId="4" Attno="2" ColName="b" TypeMdid="0.701.1.0" TypeModifier="0" ColWidth="22"/>
              </dxl:Columns>
            </dxl:TableDescriptor>
          </dxl:LogicalGet>
          <dxl:And>
            <dxl:Comparison ComparisonOperator="&gt;" OperatorMdid="0.521.1.0">
              <dxl:Ident ColId="1" ColName="a" TypeMdid="0.23.1.0"/>
              <dxl:ConstValue TypeMdid="0.23.1.0" IsNull="false" IsByValue="true" Value="4"/>
            </dxl:Comparison>
            <dxl:Comparison ComparisonOperator="=" OperatorMdid="0.96.1.0">
              <dxl:Ident ColId="1" ColName="a" TypeMdid="0.23.1.0"/>
              <dxl:Ident ColId="3" ColName="a" TypeMdid="0.23.1.0"/>
            </dxl:Comparison>
            <dxl:Comparison ComparisonOperator="&gt;" OperatorMdid="0.521.1.0">
              <dxl:Ident ColId="3" ColName="a" TypeMdid="0.23.1.0"/>
              <dxl:ConstValue TypeMdid="0.23.1.0" IsNull="false" IsByValue="true" Value="4"/>
            </dxl:Comparison>
          </dxl:And>
        </dxl:LogicalJoin>
      </dxl:LogicalGroupBy>
    </dxl:Query>
    <dxl:Plan Id="0" SpaceSize="0">
      <dxl:Aggregate AggregationStrategy="Plain" StreamSafe="false">
        <dxl:Properties>
          <dxl:Cost StartupCost="0" TotalCost="862.260646" Rows="1.000000" Width="8"/>
        </dxl:Properties>
        <dxl:GroupingColumns/>
        <dxl:ProjList>
          <dxl:ProjElem ColId="4" Alias="sum(t1.a)">
            <dxl:AggFunc AggMdid="0.2108.1.0" AggDistinct="false" AggStage="Normal">
              <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0"/>
            </dxl:AggFunc>
          </dxl:ProjElem>
        </dxl:ProjList>
        <dxl:Filter/>
        <dxl:HashJoin JoinType="Inner">
          <dxl:Properties>
            <dxl:Cost StartupCost="0" TotalCost="862.260466" Rows="400.000000" Width="4"/>
          </dxl:Properties>
          <dxl:ProjList>
            <dxl:ProjElem ColId="0" Alias="a">
              <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0"/>
            </dxl:ProjElem>
          </dxl:ProjList>
          <dxl:Filter/>
          <dxl:JoinFilter/>
          <dxl:HashCondList>
            <dxl:Comparison ComparisonOperator="=" OperatorMdid="0.96.1.0">
              <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0"/>
              <dxl:Ident ColId="2" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0"/>
            </dxl:Comparison>
          </dxl:HashCondList>
          <dxl:TableScan>
            <dxl:Properties>
              <dxl:Cost StartupCost="0" TotalCost="431.054026" Rows="400.000000" Width="4"/>
            </dxl:Properties>
            <dxl:ProjList>
              <dxl:ProjElem ColId="0" Alias="a">
                <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0"/>
              </dxl:ProjElem>
            </dxl:ProjList>
            <dxl:Filter>
              <dxl:Comparison ComparisonOperator="&gt;" OperatorMdid="0.521.1.0">
                <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0"/>
                <dxl:ConstValue TypeMdid="0.23.1.0" IsNull="false" IsByValue="true" Value="4"/>
              </dxl:Comparison>
            </dxl:Filter>
            <dxl:TableDescriptor Mdid="0.10006.1.0" TableName="t11">
              <dxl:Columns>
                <dxl:Column ColId="0" Attno="1" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0" ColWidth="11"/>
                <dxl:Column ColId="1" Attno="2" ColName="b" TypeMdid="0.701.1.0" TypeModifier="0" ColWidth="22"/>
              </dxl:Columns>
            </dxl:TableDescriptor>
          </dxl:TableScan>
          <dxl:TableScan>
            <dxl:Properties>
              <dxl:Cost StartupCost="0" TotalCost="431.054026" Rows="400.000000" Width="4"/>
            </dxl:Properties>
            <dxl:ProjList>
              <dxl:ProjElem ColId="2" Alias="a">
                <dxl:Ident ColId="2" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0"/>
              </dxl:ProjElem>
            </dxl:ProjList>
            <dxl:Filter>
              <dxl:Comparison ComparisonOperator="&gt;" OperatorMdid="0.521.1.0">
                <dxl:Ident ColId="2" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0"/>
                <dxl:ConstValue TypeMdid="0.23.1.0" IsNull="false" IsByValue="true" Value="4"/>
              </dxl:Comparison>
            </dxl:Filter>
            <dxl:TableDescriptor Mdid="0.10006.1.0" TableName="t11">
              <dxl:Columns>
                <dxl:Column ColId="2" Attno="1" ColName="a" TypeMdid="0.23.1.0" TypeModifier="0" ColWidth="11"/>
                <dxl:Column ColId="3" Attno="2" ColName="b" TypeMdid="0.701.1.0" TypeModifier="0" ColWidth="22"/>
              </dxl:Columns>
            </dxl:TableDescriptor>
          </dxl:TableScan>
        </dxl:HashJoin>
      </dxl:Aggregate>
    </dxl:Plan>
  </dxl:Thread>
</dxl:DXLMessage>


打赏作者以资鼓励:
移动端扫码阅读: