This is an automated email from the ASF dual-hosted git repository. maxyang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit dfa9bb5bc0f3d45f87b1ff4694fdb4610171ee78 Author: hari krishna <[email protected]> AuthorDate: Mon Oct 3 22:46:39 2022 +0530 Allow direct dispatch when filtering on gp_segment_id Probelm: ORCA failed to do direct dispatch when filtering gp_segment_id on conjunction/disjunction constraints setup : #create table foo (a int); #explain select * from foo where gp_segment_id=0 and a between 1 and 10; Sol: -- This PR filterts the gp_segment_id on constraints with conjunction/disjunction -- Tries to do direct dispatch if finds gp_segment_id in constraint. --- ...ctDispatch-GpSegmentId-MultiCol-Conjunction.mdp | 334 +++++++++++++++++++++ ...tDispatch-GpSegmentId-SingleCol-Conjunction.mdp | 305 +++++++++++++++++++ .../libgpopt/include/gpopt/base/CConstraint.h | 6 + .../include/gpopt/base/CConstraintConjunction.h | 3 + .../include/gpopt/base/CConstraintInterval.h | 2 + .../libgpopt/src/base/CConstraintConjunction.cpp | 22 ++ .../libgpopt/src/base/CConstraintInterval.cpp | 19 ++ .../src/translate/CTranslatorExprToDXLUtils.cpp | 21 +- .../gpopt/minidump/CDirectDispatchTest.cpp | 2 + src/test/regress/expected/direct_dispatch.out | 146 +++++++++ .../regress/expected/direct_dispatch_optimizer.out | 145 +++++++++ src/test/regress/sql/direct_dispatch.sql | 31 ++ 12 files changed, 1027 insertions(+), 9 deletions(-) diff --git a/src/backend/gporca/data/dxl/minidump/DirectDispatch-GpSegmentId-MultiCol-Conjunction.mdp b/src/backend/gporca/data/dxl/minidump/DirectDispatch-GpSegmentId-MultiCol-Conjunction.mdp new file mode 100644 index 0000000000..c082aa52d9 --- /dev/null +++ b/src/backend/gporca/data/dxl/minidump/DirectDispatch-GpSegmentId-MultiCol-Conjunction.mdp @@ -0,0 +1,334 @@ +<?xml version="1.0" encoding="UTF-8"?> +<dxl:DXLMessage xmlns:dxl="http://greenplum.com/dxl/2010/12/"> + <dxl:Comment><![CDATA[ + Objective: Allow direct dispatch when filtering gp_segment_id on conjunction constraints + Setup: + create table bar (a int, b int); + explain select * from bar where b between 1 and 5 and gp_segment_id=2 and a between 1 and 10; + QUERY PLAN + -------------------------------------------------------------------------------------------- + Gather Motion 1:1 (slice1; segments: 1) (cost=0.00..431.00 rows=1 width=8) + -> Seq Scan on bar (cost=0.00..431.00 rows=1 width=8) + Filter: ((b >= 1) AND (b <= 5) AND (gp_segment_id = 2) AND (a >= 1) AND (a <= 10)) + Optimizer: Pivotal Optimizer (GPORCA) + ]]></dxl:Comment> + <dxl:Thread Id="0"> + <dxl:OptimizerConfig> + <dxl:EnumeratorConfig Id="0" PlanSamples="0" CostThreshold="0"/> + <dxl:StatisticsConfig DampingFactorFilter="0.750000" DampingFactorJoin="0.000000" DampingFactorGroupBy="0.750000" MaxStatsBuckets="100"/> + <dxl:CTEConfig CTEInliningCutoff="0"/> + <dxl:WindowOids RowNumber="3100" Rank="3101"/> + <dxl:CostModelConfig CostModelType="1" SegmentsForCosting="3"> + <dxl:CostParams> + <dxl:CostParam Name="NLJFactor" Value="1024.000000" LowerBound="1023.500000" UpperBound="1024.500000"/> + </dxl:CostParams> + </dxl:CostModelConfig> + <dxl:Hint MinNumOfPartsToRequireSortOnInsert="2147483647" JoinArityForAssociativityCommutativity="18" ArrayExpansionThreshold="100" JoinOrderDynamicProgThreshold="10" BroadcastThreshold="100000" EnforceConstraintsOnDML="false" PushGroupByBelowSetopThreshold="10" XformBindThreshold="0"/> + <dxl:TraceFlags Value="101013,102001,102002,102003,102043,102074,102120,102144,103001,103014,103022,103026,103027,103029,103033,103038,103040,104002,104003,104004,104005,106000"/> + </dxl:OptimizerConfig> + <dxl:Metadata SystemIds="0.GPDB"> + <dxl:GPDBScalarOp Mdid="0.523.1.0" Name="<=" ComparisonType="LEq" ReturnsNullOnNullInput="true" IsNDVPreserving="false"> + <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.149.1.0"/> + <dxl:Commutator Mdid="0.525.1.0"/> + <dxl:InverseOp Mdid="0.521.1.0"/> + <dxl:Opfamilies> + <dxl:Opfamily Mdid="0.1976.1.0"/> + <dxl:Opfamily Mdid="0.4054.1.0"/> + <dxl:Opfamily Mdid="0.10009.1.0"/> + </dxl:Opfamilies> + </dxl:GPDBScalarOp> + <dxl:GPDBScalarOp Mdid="0.525.1.0" Name=">=" ComparisonType="GEq" ReturnsNullOnNullInput="true" IsNDVPreserving="false"> + <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.150.1.0"/> + <dxl:Commutator Mdid="0.523.1.0"/> + <dxl:InverseOp Mdid="0.97.1.0"/> + <dxl:Opfamilies> + <dxl:Opfamily Mdid="0.1976.1.0"/> + <dxl:Opfamily Mdid="0.4054.1.0"/> + <dxl:Opfamily Mdid="0.10009.1.0"/> + </dxl:Opfamilies> + </dxl:GPDBScalarOp> + <dxl:Type Mdid="0.16.1.0" Name="bool" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="1" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.2222.1.0"/> + <dxl:LegacyDistrOpfamily Mdid="0.7124.1.0"/> + <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.23.1.0" Name="int4" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="4" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.1977.1.0"/> + <dxl:LegacyDistrOpfamily Mdid="0.7100.1.0"/> + <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:Type Mdid="0.26.1.0" Name="oid" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="4" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.1990.1.0"/> + <dxl:LegacyDistrOpfamily Mdid="0.7109.1.0"/> + <dxl:EqualityOp Mdid="0.607.1.0"/> + <dxl:InequalityOp Mdid="0.608.1.0"/> + <dxl:LessThanOp Mdid="0.609.1.0"/> + <dxl:LessThanEqualsOp Mdid="0.611.1.0"/> + <dxl:GreaterThanOp Mdid="0.610.1.0"/> + <dxl:GreaterThanEqualsOp Mdid="0.612.1.0"/> + <dxl:ComparisonOp Mdid="0.356.1.0"/> + <dxl:ArrayType Mdid="0.1028.1.0"/> + <dxl:MinAgg Mdid="0.2118.1.0"/> + <dxl:MaxAgg Mdid="0.2134.1.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.27.1.0" Name="tid" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="6" PassByValue="false"> + <dxl:DistrOpfamily Mdid="0.2227.1.0"/> + <dxl:LegacyDistrOpfamily Mdid="0.7110.1.0"/> + <dxl:EqualityOp Mdid="0.387.1.0"/> + <dxl:InequalityOp Mdid="0.402.1.0"/> + <dxl:LessThanOp Mdid="0.2799.1.0"/> + <dxl:LessThanEqualsOp Mdid="0.2801.1.0"/> + <dxl:GreaterThanOp Mdid="0.2800.1.0"/> + <dxl:GreaterThanEqualsOp Mdid="0.2802.1.0"/> + <dxl:ComparisonOp Mdid="0.2794.1.0"/> + <dxl:ArrayType Mdid="0.1010.1.0"/> + <dxl:MinAgg Mdid="0.2798.1.0"/> + <dxl:MaxAgg Mdid="0.2797.1.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.29.1.0" Name="cid" IsRedistributable="true" IsHashable="true" IsMergeJoinable="false" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="4" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.2226.1.0"/> + <dxl:EqualityOp Mdid="0.385.1.0"/> + <dxl:InequalityOp Mdid="0.0.0.0"/> + <dxl:LessThanOp Mdid="0.0.0.0"/> + <dxl:LessThanEqualsOp Mdid="0.0.0.0"/> + <dxl:GreaterThanOp Mdid="0.0.0.0"/> + <dxl:GreaterThanEqualsOp Mdid="0.0.0.0"/> + <dxl:ComparisonOp Mdid="0.0.0.0"/> + <dxl:ArrayType Mdid="0.1012.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.28.1.0" Name="xid" IsRedistributable="true" IsHashable="true" IsMergeJoinable="false" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="4" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.2225.1.0"/> + <dxl:EqualityOp Mdid="0.352.1.0"/> + <dxl:InequalityOp Mdid="0.3315.1.0"/> + <dxl:LessThanOp Mdid="0.0.0.0"/> + <dxl:LessThanEqualsOp Mdid="0.0.0.0"/> + <dxl:GreaterThanOp Mdid="0.0.0.0"/> + <dxl:GreaterThanEqualsOp Mdid="0.0.0.0"/> + <dxl:ComparisonOp Mdid="0.0.0.0"/> + <dxl:ArrayType Mdid="0.1011.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:RelationStatistics Mdid="2.32561.1.0" Name="bar" Rows="0.000000" RelPages="0" RelAllVisible="0" EmptyRelation="true"/> + <dxl:Relation Mdid="0.32561.1.0" Name="bar" IsTemporary="false" HasOids="false" StorageType="Heap" DistributionPolicy="Hash" DistributionColumns="0" Keys="8,2" NumberLeafPartitions="0"> + <dxl:Columns> + <dxl:Column Name="a" Attno="1" Mdid="0.23.1.0" Nullable="true" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="b" Attno="2" Mdid="0.23.1.0" Nullable="true" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="ctid" Attno="-1" Mdid="0.27.1.0" Nullable="false" ColWidth="6"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="xmin" Attno="-2" Mdid="0.28.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="cmin" Attno="-3" Mdid="0.29.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="xmax" Attno="-4" Mdid="0.28.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="cmax" Attno="-5" Mdid="0.29.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="tableoid" Attno="-6" Mdid="0.26.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="gp_segment_id" Attno="-7" Mdid="0.23.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + </dxl:Columns> + <dxl:IndexInfoList/> + <dxl:Triggers/> + <dxl:CheckConstraints/> + <dxl:DistrOpfamilies> + <dxl:DistrOpfamily Mdid="0.1977.1.0"/> + </dxl:DistrOpfamilies> + </dxl:Relation> + <dxl:ColumnStatistics Mdid="1.32561.1.0.8" Name="gp_segment_id" Width="4.000000" NullFreq="0.000000" NdvRemain="0.000000" FreqRemain="0.000000" ColStatsMissing="true"/> + <dxl:ColumnStatistics Mdid="1.32561.1.0.1" Name="b" Width="4.000000" NullFreq="0.000000" NdvRemain="0.000000" FreqRemain="0.000000" ColStatsMissing="true"/> + <dxl:ColumnStatistics Mdid="1.32561.1.0.0" Name="a" Width="4.000000" NullFreq="0.000000" NdvRemain="0.000000" FreqRemain="0.000000" ColStatsMissing="true"/> + <dxl:GPDBScalarOp Mdid="0.96.1.0" Name="=" ComparisonType="Eq" ReturnsNullOnNullInput="true" IsNDVPreserving="false"> + <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:Commutator Mdid="0.96.1.0"/> + <dxl:InverseOp Mdid="0.518.1.0"/> + <dxl:HashOpfamily Mdid="0.1977.1.0"/> + <dxl:LegacyHashOpfamily Mdid="0.7100.1.0"/> + <dxl:Opfamilies> + <dxl:Opfamily Mdid="0.1976.1.0"/> + <dxl:Opfamily Mdid="0.1977.1.0"/> + <dxl:Opfamily Mdid="0.4054.1.0"/> + <dxl:Opfamily Mdid="0.7100.1.0"/> + <dxl:Opfamily Mdid="0.10009.1.0"/> + </dxl:Opfamilies> + </dxl:GPDBScalarOp> + </dxl:Metadata> + <dxl:Query> + <dxl:OutputColumns> + <dxl:Ident ColId="1" ColName="a" TypeMdid="0.23.1.0"/> + <dxl:Ident ColId="2" ColName="b" TypeMdid="0.23.1.0"/> + </dxl:OutputColumns> + <dxl:CTEList/> + <dxl:LogicalSelect> + <dxl:And> + <dxl:Comparison ComparisonOperator=">=" OperatorMdid="0.525.1.0"> + <dxl:Ident ColId="2" ColName="b" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="1"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator="<=" OperatorMdid="0.523.1.0"> + <dxl:Ident ColId="2" ColName="b" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="5"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator="=" OperatorMdid="0.96.1.0"> + <dxl:Ident ColId="9" ColName="gp_segment_id" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="2"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator=">=" OperatorMdid="0.525.1.0"> + <dxl:Ident ColId="1" ColName="a" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="1"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator="<=" OperatorMdid="0.523.1.0"> + <dxl:Ident ColId="1" ColName="a" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="10"/> + </dxl:Comparison> + </dxl:And> + <dxl:LogicalGet> + <dxl:TableDescriptor Mdid="0.32561.1.0" TableName="bar" LockMode="1"> + <dxl:Columns> + <dxl:Column ColId="1" Attno="1" ColName="a" TypeMdid="0.23.1.0" ColWidth="4"/> + <dxl:Column ColId="2" Attno="2" ColName="b" TypeMdid="0.23.1.0" ColWidth="4"/> + <dxl:Column ColId="3" Attno="-1" ColName="ctid" TypeMdid="0.27.1.0" ColWidth="6"/> + <dxl:Column ColId="4" Attno="-2" ColName="xmin" TypeMdid="0.28.1.0" ColWidth="4"/> + <dxl:Column ColId="5" Attno="-3" ColName="cmin" TypeMdid="0.29.1.0" ColWidth="4"/> + <dxl:Column ColId="6" Attno="-4" ColName="xmax" TypeMdid="0.28.1.0" ColWidth="4"/> + <dxl:Column ColId="7" Attno="-5" ColName="cmax" TypeMdid="0.29.1.0" ColWidth="4"/> + <dxl:Column ColId="8" Attno="-6" ColName="tableoid" TypeMdid="0.26.1.0" ColWidth="4"/> + <dxl:Column ColId="9" Attno="-7" ColName="gp_segment_id" TypeMdid="0.23.1.0" ColWidth="4"/> + </dxl:Columns> + </dxl:TableDescriptor> + </dxl:LogicalGet> + </dxl:LogicalSelect> + </dxl:Query> + <dxl:Plan Id="0" SpaceSize="1"> + <dxl:GatherMotion InputSegments="0,1,2" OutputSegments="-1"> + <dxl:Properties> + <dxl:Cost StartupCost="0" TotalCost="431.000157" Rows="1.000000" Width="8"/> + </dxl:Properties> + <dxl:ProjList> + <dxl:ProjElem ColId="0" Alias="a"> + <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0"/> + </dxl:ProjElem> + <dxl:ProjElem ColId="1" Alias="b"> + <dxl:Ident ColId="1" ColName="b" TypeMdid="0.23.1.0"/> + </dxl:ProjElem> + </dxl:ProjList> + <dxl:Filter/> + <dxl:SortingColumnList/> + <dxl:TableScan> + <dxl:Properties> + <dxl:Cost StartupCost="0" TotalCost="431.000127" Rows="1.000000" Width="8"/> + </dxl:Properties> + <dxl:ProjList> + <dxl:ProjElem ColId="0" Alias="a"> + <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0"/> + </dxl:ProjElem> + <dxl:ProjElem ColId="1" Alias="b"> + <dxl:Ident ColId="1" ColName="b" TypeMdid="0.23.1.0"/> + </dxl:ProjElem> + </dxl:ProjList> + <dxl:Filter> + <dxl:And> + <dxl:Comparison ComparisonOperator=">=" OperatorMdid="0.525.1.0"> + <dxl:Ident ColId="1" ColName="b" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="1"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator="<=" OperatorMdid="0.523.1.0"> + <dxl:Ident ColId="1" ColName="b" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="5"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator="=" OperatorMdid="0.96.1.0"> + <dxl:Ident ColId="8" ColName="gp_segment_id" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="2"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator=">=" OperatorMdid="0.525.1.0"> + <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="1"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator="<=" OperatorMdid="0.523.1.0"> + <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="10"/> + </dxl:Comparison> + </dxl:And> + </dxl:Filter> + <dxl:TableDescriptor Mdid="0.32561.1.0" TableName="bar" LockMode="1"> + <dxl:Columns> + <dxl:Column ColId="0" Attno="1" ColName="a" TypeMdid="0.23.1.0" ColWidth="4"/> + <dxl:Column ColId="1" Attno="2" ColName="b" TypeMdid="0.23.1.0" ColWidth="4"/> + <dxl:Column ColId="2" Attno="-1" ColName="ctid" TypeMdid="0.27.1.0" ColWidth="6"/> + <dxl:Column ColId="3" Attno="-2" ColName="xmin" TypeMdid="0.28.1.0" ColWidth="4"/> + <dxl:Column ColId="4" Attno="-3" ColName="cmin" TypeMdid="0.29.1.0" ColWidth="4"/> + <dxl:Column ColId="5" Attno="-4" ColName="xmax" TypeMdid="0.28.1.0" ColWidth="4"/> + <dxl:Column ColId="6" Attno="-5" ColName="cmax" TypeMdid="0.29.1.0" ColWidth="4"/> + <dxl:Column ColId="7" Attno="-6" ColName="tableoid" TypeMdid="0.26.1.0" ColWidth="4"/> + <dxl:Column ColId="8" Attno="-7" ColName="gp_segment_id" TypeMdid="0.23.1.0" ColWidth="4"/> + </dxl:Columns> + </dxl:TableDescriptor> + </dxl:TableScan> + </dxl:GatherMotion> + <dxl:DirectDispatchInfo IsRaw="true"> + <dxl:KeyValue> + <dxl:Datum TypeMdid="0.23.1.0" Value="2"/> + </dxl:KeyValue> + </dxl:DirectDispatchInfo> + </dxl:Plan> + </dxl:Thread> +</dxl:DXLMessage> diff --git a/src/backend/gporca/data/dxl/minidump/DirectDispatch-GpSegmentId-SingleCol-Conjunction.mdp b/src/backend/gporca/data/dxl/minidump/DirectDispatch-GpSegmentId-SingleCol-Conjunction.mdp new file mode 100644 index 0000000000..eb2356d6ac --- /dev/null +++ b/src/backend/gporca/data/dxl/minidump/DirectDispatch-GpSegmentId-SingleCol-Conjunction.mdp @@ -0,0 +1,305 @@ +<?xml version="1.0" encoding="UTF-8"?> +<dxl:DXLMessage xmlns:dxl="http://greenplum.com/dxl/2010/12/"> + <dxl:Comment><![CDATA[ + Objective: Allow direct dispatch when filtering gp_segment_id on conjunction constraints + Setup: + create table foo (a int); + explain select * from foo where gp_segment_id=2 and a between 1 and 10; + QUERY PLAN + ------------------------------------------------------------------------------ + Gather Motion 1:1 (slice1; segments: 1) (cost=0.00..431.00 rows=1 width=4) + -> Seq Scan on foo (cost=0.00..431.00 rows=1 width=4) + Filter: ((gp_segment_id = 2) AND (a >= 1) AND (a <= 10)) + Optimizer: Pivotal Optimizer (GPORCA) + ]]></dxl:Comment> + <dxl:Thread Id="0"> + <dxl:OptimizerConfig> + <dxl:EnumeratorConfig Id="0" PlanSamples="0" CostThreshold="0"/> + <dxl:StatisticsConfig DampingFactorFilter="0.750000" DampingFactorJoin="0.000000" DampingFactorGroupBy="0.750000" MaxStatsBuckets="100"/> + <dxl:CTEConfig CTEInliningCutoff="0"/> + <dxl:WindowOids RowNumber="3100" Rank="3101"/> + <dxl:CostModelConfig CostModelType="1" SegmentsForCosting="3"> + <dxl:CostParams> + <dxl:CostParam Name="NLJFactor" Value="1024.000000" LowerBound="1023.500000" UpperBound="1024.500000"/> + </dxl:CostParams> + </dxl:CostModelConfig> + <dxl:Hint MinNumOfPartsToRequireSortOnInsert="2147483647" JoinArityForAssociativityCommutativity="18" ArrayExpansionThreshold="100" JoinOrderDynamicProgThreshold="10" BroadcastThreshold="100000" EnforceConstraintsOnDML="false" PushGroupByBelowSetopThreshold="10" XformBindThreshold="0"/> + <dxl:TraceFlags Value="101013,102001,102002,102003,102043,102074,102120,102144,103001,103014,103022,103026,103027,103029,103033,103038,103040,104002,104003,104004,104005,106000"/> + </dxl:OptimizerConfig> + <dxl:Metadata SystemIds="0.GPDB"> + <dxl:GPDBScalarOp Mdid="0.523.1.0" Name="<=" ComparisonType="LEq" ReturnsNullOnNullInput="true" IsNDVPreserving="false"> + <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.149.1.0"/> + <dxl:Commutator Mdid="0.525.1.0"/> + <dxl:InverseOp Mdid="0.521.1.0"/> + <dxl:Opfamilies> + <dxl:Opfamily Mdid="0.1976.1.0"/> + <dxl:Opfamily Mdid="0.4054.1.0"/> + <dxl:Opfamily Mdid="0.10009.1.0"/> + </dxl:Opfamilies> + </dxl:GPDBScalarOp> + <dxl:GPDBScalarOp Mdid="0.525.1.0" Name=">=" ComparisonType="GEq" ReturnsNullOnNullInput="true" IsNDVPreserving="false"> + <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.150.1.0"/> + <dxl:Commutator Mdid="0.523.1.0"/> + <dxl:InverseOp Mdid="0.97.1.0"/> + <dxl:Opfamilies> + <dxl:Opfamily Mdid="0.1976.1.0"/> + <dxl:Opfamily Mdid="0.4054.1.0"/> + <dxl:Opfamily Mdid="0.10009.1.0"/> + </dxl:Opfamilies> + </dxl:GPDBScalarOp> + <dxl:Type Mdid="0.16.1.0" Name="bool" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="1" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.2222.1.0"/> + <dxl:LegacyDistrOpfamily Mdid="0.7124.1.0"/> + <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.23.1.0" Name="int4" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="4" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.1977.1.0"/> + <dxl:LegacyDistrOpfamily Mdid="0.7100.1.0"/> + <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:Type Mdid="0.26.1.0" Name="oid" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="4" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.1990.1.0"/> + <dxl:LegacyDistrOpfamily Mdid="0.7109.1.0"/> + <dxl:EqualityOp Mdid="0.607.1.0"/> + <dxl:InequalityOp Mdid="0.608.1.0"/> + <dxl:LessThanOp Mdid="0.609.1.0"/> + <dxl:LessThanEqualsOp Mdid="0.611.1.0"/> + <dxl:GreaterThanOp Mdid="0.610.1.0"/> + <dxl:GreaterThanEqualsOp Mdid="0.612.1.0"/> + <dxl:ComparisonOp Mdid="0.356.1.0"/> + <dxl:ArrayType Mdid="0.1028.1.0"/> + <dxl:MinAgg Mdid="0.2118.1.0"/> + <dxl:MaxAgg Mdid="0.2134.1.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.27.1.0" Name="tid" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="6" PassByValue="false"> + <dxl:DistrOpfamily Mdid="0.2227.1.0"/> + <dxl:LegacyDistrOpfamily Mdid="0.7110.1.0"/> + <dxl:EqualityOp Mdid="0.387.1.0"/> + <dxl:InequalityOp Mdid="0.402.1.0"/> + <dxl:LessThanOp Mdid="0.2799.1.0"/> + <dxl:LessThanEqualsOp Mdid="0.2801.1.0"/> + <dxl:GreaterThanOp Mdid="0.2800.1.0"/> + <dxl:GreaterThanEqualsOp Mdid="0.2802.1.0"/> + <dxl:ComparisonOp Mdid="0.2794.1.0"/> + <dxl:ArrayType Mdid="0.1010.1.0"/> + <dxl:MinAgg Mdid="0.2798.1.0"/> + <dxl:MaxAgg Mdid="0.2797.1.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.29.1.0" Name="cid" IsRedistributable="true" IsHashable="true" IsMergeJoinable="false" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="4" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.2226.1.0"/> + <dxl:EqualityOp Mdid="0.385.1.0"/> + <dxl:InequalityOp Mdid="0.0.0.0"/> + <dxl:LessThanOp Mdid="0.0.0.0"/> + <dxl:LessThanEqualsOp Mdid="0.0.0.0"/> + <dxl:GreaterThanOp Mdid="0.0.0.0"/> + <dxl:GreaterThanEqualsOp Mdid="0.0.0.0"/> + <dxl:ComparisonOp Mdid="0.0.0.0"/> + <dxl:ArrayType Mdid="0.1012.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.28.1.0" Name="xid" IsRedistributable="true" IsHashable="true" IsMergeJoinable="false" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="4" PassByValue="true"> + <dxl:DistrOpfamily Mdid="0.2225.1.0"/> + <dxl:EqualityOp Mdid="0.352.1.0"/> + <dxl:InequalityOp Mdid="0.3315.1.0"/> + <dxl:LessThanOp Mdid="0.0.0.0"/> + <dxl:LessThanEqualsOp Mdid="0.0.0.0"/> + <dxl:GreaterThanOp Mdid="0.0.0.0"/> + <dxl:GreaterThanEqualsOp Mdid="0.0.0.0"/> + <dxl:ComparisonOp Mdid="0.0.0.0"/> + <dxl:ArrayType Mdid="0.1011.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:ColumnStatistics Mdid="1.32558.1.0.7" Name="gp_segment_id" Width="4.000000" NullFreq="0.000000" NdvRemain="0.000000" FreqRemain="0.000000" ColStatsMissing="true"/> + <dxl:RelationStatistics Mdid="2.32558.1.0" Name="foo" Rows="0.000000" RelPages="0" RelAllVisible="0" EmptyRelation="true"/> + <dxl:Relation Mdid="0.32558.1.0" Name="foo" IsTemporary="false" HasOids="false" StorageType="Heap" DistributionPolicy="Hash" DistributionColumns="0" Keys="7,1" NumberLeafPartitions="0"> + <dxl:Columns> + <dxl:Column Name="a" Attno="1" Mdid="0.23.1.0" Nullable="true" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="ctid" Attno="-1" Mdid="0.27.1.0" Nullable="false" ColWidth="6"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="xmin" Attno="-2" Mdid="0.28.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="cmin" Attno="-3" Mdid="0.29.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="xmax" Attno="-4" Mdid="0.28.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="cmax" Attno="-5" Mdid="0.29.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="tableoid" Attno="-6" Mdid="0.26.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + <dxl:Column Name="gp_segment_id" Attno="-7" Mdid="0.23.1.0" Nullable="false" ColWidth="4"> + <dxl:DefaultValue/> + </dxl:Column> + </dxl:Columns> + <dxl:IndexInfoList/> + <dxl:Triggers/> + <dxl:CheckConstraints/> + <dxl:DistrOpfamilies> + <dxl:DistrOpfamily Mdid="0.1977.1.0"/> + </dxl:DistrOpfamilies> + </dxl:Relation> + <dxl:ColumnStatistics Mdid="1.32558.1.0.0" Name="a" Width="4.000000" NullFreq="0.000000" NdvRemain="0.000000" FreqRemain="0.000000" ColStatsMissing="true"/> + <dxl:GPDBScalarOp Mdid="0.96.1.0" Name="=" ComparisonType="Eq" ReturnsNullOnNullInput="true" IsNDVPreserving="false"> + <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:Commutator Mdid="0.96.1.0"/> + <dxl:InverseOp Mdid="0.518.1.0"/> + <dxl:HashOpfamily Mdid="0.1977.1.0"/> + <dxl:LegacyHashOpfamily Mdid="0.7100.1.0"/> + <dxl:Opfamilies> + <dxl:Opfamily Mdid="0.1976.1.0"/> + <dxl:Opfamily Mdid="0.1977.1.0"/> + <dxl:Opfamily Mdid="0.4054.1.0"/> + <dxl:Opfamily Mdid="0.7100.1.0"/> + <dxl:Opfamily Mdid="0.10009.1.0"/> + </dxl:Opfamilies> + </dxl:GPDBScalarOp> + </dxl:Metadata> + <dxl:Query> + <dxl:OutputColumns> + <dxl:Ident ColId="1" ColName="a" TypeMdid="0.23.1.0"/> + </dxl:OutputColumns> + <dxl:CTEList/> + <dxl:LogicalSelect> + <dxl:And> + <dxl:Comparison ComparisonOperator="=" OperatorMdid="0.96.1.0"> + <dxl:Ident ColId="8" ColName="gp_segment_id" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="2"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator=">=" OperatorMdid="0.525.1.0"> + <dxl:Ident ColId="1" ColName="a" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="1"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator="<=" OperatorMdid="0.523.1.0"> + <dxl:Ident ColId="1" ColName="a" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="10"/> + </dxl:Comparison> + </dxl:And> + <dxl:LogicalGet> + <dxl:TableDescriptor Mdid="0.32558.1.0" TableName="foo" LockMode="1"> + <dxl:Columns> + <dxl:Column ColId="1" Attno="1" ColName="a" TypeMdid="0.23.1.0" ColWidth="4"/> + <dxl:Column ColId="2" Attno="-1" ColName="ctid" TypeMdid="0.27.1.0" ColWidth="6"/> + <dxl:Column ColId="3" Attno="-2" ColName="xmin" TypeMdid="0.28.1.0" ColWidth="4"/> + <dxl:Column ColId="4" Attno="-3" ColName="cmin" TypeMdid="0.29.1.0" ColWidth="4"/> + <dxl:Column ColId="5" Attno="-4" ColName="xmax" TypeMdid="0.28.1.0" ColWidth="4"/> + <dxl:Column ColId="6" Attno="-5" ColName="cmax" TypeMdid="0.29.1.0" ColWidth="4"/> + <dxl:Column ColId="7" Attno="-6" ColName="tableoid" TypeMdid="0.26.1.0" ColWidth="4"/> + <dxl:Column ColId="8" Attno="-7" ColName="gp_segment_id" TypeMdid="0.23.1.0" ColWidth="4"/> + </dxl:Columns> + </dxl:TableDescriptor> + </dxl:LogicalGet> + </dxl:LogicalSelect> + </dxl:Query> + <dxl:Plan Id="0" SpaceSize="1"> + <dxl:GatherMotion InputSegments="0,1,2" OutputSegments="-1"> + <dxl:Properties> + <dxl:Cost StartupCost="0" TotalCost="431.000104" Rows="1.000000" Width="4"/> + </dxl:Properties> + <dxl:ProjList> + <dxl:ProjElem ColId="0" Alias="a"> + <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0"/> + </dxl:ProjElem> + </dxl:ProjList> + <dxl:Filter/> + <dxl:SortingColumnList/> + <dxl:TableScan> + <dxl:Properties> + <dxl:Cost StartupCost="0" TotalCost="431.000089" Rows="1.000000" Width="4"/> + </dxl:Properties> + <dxl:ProjList> + <dxl:ProjElem ColId="0" Alias="a"> + <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0"/> + </dxl:ProjElem> + </dxl:ProjList> + <dxl:Filter> + <dxl:And> + <dxl:Comparison ComparisonOperator="=" OperatorMdid="0.96.1.0"> + <dxl:Ident ColId="7" ColName="gp_segment_id" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="2"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator=">=" OperatorMdid="0.525.1.0"> + <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="1"/> + </dxl:Comparison> + <dxl:Comparison ComparisonOperator="<=" OperatorMdid="0.523.1.0"> + <dxl:Ident ColId="0" ColName="a" TypeMdid="0.23.1.0"/> + <dxl:ConstValue TypeMdid="0.23.1.0" Value="10"/> + </dxl:Comparison> + </dxl:And> + </dxl:Filter> + <dxl:TableDescriptor Mdid="0.32558.1.0" TableName="foo" LockMode="1"> + <dxl:Columns> + <dxl:Column ColId="0" Attno="1" ColName="a" TypeMdid="0.23.1.0" ColWidth="4"/> + <dxl:Column ColId="1" Attno="-1" ColName="ctid" TypeMdid="0.27.1.0" ColWidth="6"/> + <dxl:Column ColId="2" Attno="-2" ColName="xmin" TypeMdid="0.28.1.0" ColWidth="4"/> + <dxl:Column ColId="3" Attno="-3" ColName="cmin" TypeMdid="0.29.1.0" ColWidth="4"/> + <dxl:Column ColId="4" Attno="-4" ColName="xmax" TypeMdid="0.28.1.0" ColWidth="4"/> + <dxl:Column ColId="5" Attno="-5" ColName="cmax" TypeMdid="0.29.1.0" ColWidth="4"/> + <dxl:Column ColId="6" Attno="-6" ColName="tableoid" TypeMdid="0.26.1.0" ColWidth="4"/> + <dxl:Column ColId="7" Attno="-7" ColName="gp_segment_id" TypeMdid="0.23.1.0" ColWidth="4"/> + </dxl:Columns> + </dxl:TableDescriptor> + </dxl:TableScan> + </dxl:GatherMotion> + <dxl:DirectDispatchInfo IsRaw="true"> + <dxl:KeyValue> + <dxl:Datum TypeMdid="0.23.1.0" Value="2"/> + </dxl:KeyValue> + </dxl:DirectDispatchInfo> + </dxl:Plan> + </dxl:Thread> +</dxl:DXLMessage> diff --git a/src/backend/gporca/libgpopt/include/gpopt/base/CConstraint.h b/src/backend/gporca/libgpopt/include/gpopt/base/CConstraint.h index d38b39f2bd..9ce610f64d 100644 --- a/src/backend/gporca/libgpopt/include/gpopt/base/CConstraint.h +++ b/src/backend/gporca/libgpopt/include/gpopt/base/CConstraint.h @@ -207,6 +207,12 @@ public: return false; } + virtual CConstraint * + GetConstraintOnSegmentId() const + { + return nullptr; + } + // return a copy of the constraint with remapped columns virtual CConstraint *PcnstrCopyWithRemappedColumns( CMemoryPool *mp, UlongToColRefMap *colref_mapping, BOOL must_exist) = 0; diff --git a/src/backend/gporca/libgpopt/include/gpopt/base/CConstraintConjunction.h b/src/backend/gporca/libgpopt/include/gpopt/base/CConstraintConjunction.h index bed84e818d..2a586569d9 100644 --- a/src/backend/gporca/libgpopt/include/gpopt/base/CConstraintConjunction.h +++ b/src/backend/gporca/libgpopt/include/gpopt/base/CConstraintConjunction.h @@ -86,6 +86,9 @@ public: CConstraint *PcnstrRemapForColumn(CMemoryPool *mp, CColRef *colref) const override; + // Returns the constraint for system column gp_segment_id + CConstraint *GetConstraintOnSegmentId() const override; + // print IOstream & OsPrint(IOstream &os) const override diff --git a/src/backend/gporca/libgpopt/include/gpopt/base/CConstraintInterval.h b/src/backend/gporca/libgpopt/include/gpopt/base/CConstraintInterval.h index b8286ccbfe..0953bd4af6 100644 --- a/src/backend/gporca/libgpopt/include/gpopt/base/CConstraintInterval.h +++ b/src/backend/gporca/libgpopt/include/gpopt/base/CConstraintInterval.h @@ -176,6 +176,8 @@ public: CDXLTokens::GetDXLTokenStr(EdxltokenGpSegmentIdColName)); } + CConstraint *GetConstraintOnSegmentId() const override; + // return a copy of the constraint with remapped columns CConstraint *PcnstrCopyWithRemappedColumns(CMemoryPool *mp, UlongToColRefMap *colref_mapping, diff --git a/src/backend/gporca/libgpopt/src/base/CConstraintConjunction.cpp b/src/backend/gporca/libgpopt/src/base/CConstraintConjunction.cpp index 6f58bc10bd..c4939a94ce 100644 --- a/src/backend/gporca/libgpopt/src/base/CConstraintConjunction.cpp +++ b/src/backend/gporca/libgpopt/src/base/CConstraintConjunction.cpp @@ -230,4 +230,26 @@ CConstraintConjunction::PexprScalar(CMemoryPool *mp) return m_pexprScalar; } +//--------------------------------------------------------------------------- +// @function: +// CConstraintConjunction::GetConstraintOnSegmentId +// +// @doc: +// Returns the constraint for system column gp_segment_id +// +//--------------------------------------------------------------------------- +CConstraint * +CConstraintConjunction::GetConstraintOnSegmentId() const +{ + for (ULONG ul = 0; ul < m_pdrgpcnstr->Size(); ul++) + { + CConstraint *pcnstr = (*m_pdrgpcnstr)[ul]; + if (pcnstr->FConstraintOnSegmentId()) + { + return pcnstr; + } + } + return nullptr; +} + // EOF diff --git a/src/backend/gporca/libgpopt/src/base/CConstraintInterval.cpp b/src/backend/gporca/libgpopt/src/base/CConstraintInterval.cpp index 5108895d93..fc0f4c3b3b 100644 --- a/src/backend/gporca/libgpopt/src/base/CConstraintInterval.cpp +++ b/src/backend/gporca/libgpopt/src/base/CConstraintInterval.cpp @@ -110,6 +110,25 @@ CConstraintInterval::PcnstrCopyWithRemappedColumns( return PcnstrRemapForColumn(mp, colref); } +//--------------------------------------------------------------------------- +// @function: +// CConstraintInterval::GetConstraintOnSegmentId +// +// @doc: +// Returns the constraint for system column gp_segment_id +// +//--------------------------------------------------------------------------- + +CConstraint * +CConstraintInterval::GetConstraintOnSegmentId() const +{ + if (FConstraintOnSegmentId()) + { + return (CConstraint *) this; + } + + return nullptr; +} //--------------------------------------------------------------------------- // @function: // CConstraintInterval::PciIntervalFromScalarExpr diff --git a/src/backend/gporca/libgpopt/src/translate/CTranslatorExprToDXLUtils.cpp b/src/backend/gporca/libgpopt/src/translate/CTranslatorExprToDXLUtils.cpp index 9e008c3856..05de0bb8ed 100644 --- a/src/backend/gporca/libgpopt/src/translate/CTranslatorExprToDXLUtils.cpp +++ b/src/backend/gporca/libgpopt/src/translate/CTranslatorExprToDXLUtils.cpp @@ -1416,18 +1416,21 @@ CTranslatorExprToDXLUtils::PdxlddinfoSingleDistrKey(CMemoryPool *mp, BOOL useRawValues = false; CConstraint *pcnstrDistrCol = pcnstr->Pcnstr(mp, pcrDistrCol); CConstraintInterval *pcnstrInterval; - if (pcnstrDistrCol == nullptr && - (pcnstrInterval = dynamic_cast<CConstraintInterval *>(pcnstr))) + // Avoid direct dispatch when pcnstrDistrCol specifies a constant column + if (!CPredicateUtils::FConstColumn(pcnstrDistrCol, pcrDistrCol) && + (pcnstrInterval = dynamic_cast<CConstraintInterval *>( + pcnstr->GetConstraintOnSegmentId())) != nullptr) { - if (pcnstrInterval->FConstraintOnSegmentId()) + if (pcnstrDistrCol != nullptr) { - // If the constraint is on gp_segment_id then we trick ourselves into - // considering the constraint as being on a distribution column. - pcnstrDistrCol = pcnstr; - pcnstrDistrCol->AddRef(); - pcrDistrCol = pcnstrInterval->Pcr(); - useRawValues = true; + pcnstrDistrCol->Release(); } + // If the constraint is on gp_segment_id then we trick ourselves into + // considering the constraint as being on a distribution column. + pcnstrDistrCol = pcnstrInterval; + pcnstrDistrCol->AddRef(); + pcrDistrCol = pcnstrInterval->Pcr(); + useRawValues = true; } CDXLDatum2dArray *pdrgpdrgpdxldatum = nullptr; diff --git a/src/backend/gporca/server/src/unittest/gpopt/minidump/CDirectDispatchTest.cpp b/src/backend/gporca/server/src/unittest/gpopt/minidump/CDirectDispatchTest.cpp index 5cae219e6b..d43eba38a4 100644 --- a/src/backend/gporca/server/src/unittest/gpopt/minidump/CDirectDispatchTest.cpp +++ b/src/backend/gporca/server/src/unittest/gpopt/minidump/CDirectDispatchTest.cpp @@ -30,6 +30,8 @@ ULONG CDirectDispatchTest::m_ulDirectDispatchCounter = const CHAR *rgszDirectDispatchFileNames[] = { "../data/dxl/minidump/DirectDispatch-SingleCol.mdp", "../data/dxl/minidump/DirectDispatch-GpSegmentId.mdp", + "../data/dxl/minidump/DirectDispatch-GpSegmentId-SingleCol-Conjunction.mdp", + "../data/dxl/minidump/DirectDispatch-GpSegmentId-MultiCol-Conjunction.mdp", "../data/dxl/minidump/DirectDispatch-SingleCol-Disjunction.mdp", "../data/dxl/minidump/DirectDispatch-SingleCol-Disjunction-IsNull.mdp", "../data/dxl/minidump/DirectDispatch-SingleCol-Disjunction-Negative.mdp", diff --git a/src/test/regress/expected/direct_dispatch.out b/src/test/regress/expected/direct_dispatch.out index 5e809458d6..0bc86776b9 100644 --- a/src/test/regress/expected/direct_dispatch.out +++ b/src/test/regress/expected/direct_dispatch.out @@ -761,6 +761,152 @@ INFO: (slice 1) Dispatch command to ALL contents: 0 1 2 2 | 2 (3 rows) +-- test direct dispatch via gp_segment_id qual with conjunction +create table t_test_dd_via_segid_conj(a int, b int); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2 +INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 +insert into t_test_dd_via_segid_conj select i,i from generate_series(1, 10)i; +INFO: (slice 0) Dispatch command to ALL contents: 0 1 2 +INFO: (slice 1) Dispatch command to SINGLE content +INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2 +INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where gp_segment_id=0 and a between 1 and 10; + QUERY PLAN +------------------------------------------------------------------ + Gather Motion 1:1 (slice1; segments: 1) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((a >= 1) AND (a <= 10) AND (gp_segment_id = 0)) + Optimizer: Postgres query optimizer +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where gp_segment_id=0 and a between 1 and 10; +INFO: (slice 1) Dispatch command to SINGLE content + gp_segment_id | a | b +---------------+---+--- + 0 | 2 | 2 + 0 | 3 | 3 + 0 | 4 | 4 + 0 | 7 | 7 + 0 | 8 | 8 +(5 rows) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where b between 1 and 5 and gp_segment_id=2 and a between 1 and 10; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Gather Motion 1:1 (slice1; segments: 1) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((b >= 1) AND (b <= 5) AND (a >= 1) AND (a <= 10) AND (gp_segment_id = 2)) + Optimizer: Postgres query optimizer +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where b between 1 and 5 and gp_segment_id=2 and a between 1 and 10; +INFO: (slice 1) Dispatch command to SINGLE content + gp_segment_id | a | b +---------------+---+--- + 2 | 5 | 5 +(1 row) + +--test direct dispatch via gp_segment_id with disjunction +explain (costs off) select * from t_test_dd_via_segid_conj where gp_segment_id=1 or (a=3 and gp_segment_id=2); + QUERY PLAN +---------------------------------------------------------------------------- + Gather Motion 2:1 (slice1; segments: 2) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((gp_segment_id = 1) OR ((a = 3) AND (gp_segment_id = 2))) + Optimizer: Postgres query optimizer +(4 rows) + +select * from t_test_dd_via_segid_conj where gp_segment_id=1 or (a=3 and gp_segment_id=2); +INFO: (slice 1) Dispatch command to PARTIAL contents: 1 2 + a | b +---+--- + 1 | 1 +(1 row) + +--test direct dispatch with constant distribution column and constant/variable gp_segment_id condition +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id in (0,1); + QUERY PLAN +----------------------------------------------------------------------------------------------------- + Gather Motion 2:1 (slice1; segments: 2) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((b >= 1) AND (b <= 10) AND (gp_segment_id = ANY ('{0,1}'::integer[])) AND (a = 3)) + Optimizer: Postgres query optimizer +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id in (0,1); +INFO: (slice 1) Dispatch command to PARTIAL contents: 1 0 + gp_segment_id | a | b +---------------+---+--- + 0 | 3 | 3 +(1 row) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id <>1; + QUERY PLAN +------------------------------------------------------------------------------- + Gather Motion 1:1 (slice1; segments: 1) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((b >= 1) AND (b <= 10) AND (gp_segment_id <> 1) AND (a = 3)) + Optimizer: Postgres query optimizer +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id <>1; +INFO: (slice 1) Dispatch command to SINGLE content + gp_segment_id | a | b +---------------+---+--- + 0 | 3 | 3 +(1 row) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 100 and gp_segment_id =0; + QUERY PLAN +------------------------------------------------------------------------------- + Gather Motion 1:1 (slice1; segments: 1) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((b >= 1) AND (b <= 100) AND (a = 3) AND (gp_segment_id = 0)) + Optimizer: Postgres query optimizer +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 100 and gp_segment_id =0; +INFO: (slice 1) Dispatch command to SINGLE content + gp_segment_id | a | b +---------------+---+--- + 0 | 3 | 3 +(1 row) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id <> 0; + QUERY PLAN +--------------------------------------------------------------------------- + Gather Motion 2:1 (slice1; segments: 2) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((a = ANY ('{1,3}'::integer[])) AND (gp_segment_id <> 0)) + Optimizer: Postgres query optimizer +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id <> 0; +INFO: (slice 1) Dispatch command to PARTIAL contents: 1 0 + gp_segment_id | a | b +---------------+---+--- + 1 | 1 | 1 +(1 row) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id in (0,1); + QUERY PLAN +------------------------------------------------------------------------------------------------- + Gather Motion 2:1 (slice1; segments: 2) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((a = ANY ('{1,3}'::integer[])) AND (gp_segment_id = ANY ('{0,1}'::integer[]))) + Optimizer: Postgres query optimizer +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id in (0,1); +INFO: (slice 1) Dispatch command to PARTIAL contents: 1 0 + gp_segment_id | a | b +---------------+---+--- + 0 | 3 | 3 + 1 | 1 | 1 +(2 rows) + -- test direct dispatch via SQLValueFunction and FuncExpr for single row insertion. create table t_sql_value_function1 (a int, b date); NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Cloudberry Database data distribution key for this table. diff --git a/src/test/regress/expected/direct_dispatch_optimizer.out b/src/test/regress/expected/direct_dispatch_optimizer.out index de8aeef58e..bff3b4f19c 100644 --- a/src/test/regress/expected/direct_dispatch_optimizer.out +++ b/src/test/regress/expected/direct_dispatch_optimizer.out @@ -774,6 +774,151 @@ INFO: (slice 1) Dispatch command to ALL contents: 0 1 2 2 | 2 (3 rows) +-- test direct dispatch via gp_segment_id qual with conjunction +create table t_test_dd_via_segid_conj(a int, b int); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2 +INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 +insert into t_test_dd_via_segid_conj select i,i from generate_series(1, 10)i; +INFO: (slice 0) Dispatch command to ALL contents: 0 1 2 +INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2 +INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where gp_segment_id=0 and a between 1 and 10; + QUERY PLAN +------------------------------------------------------------------ + Gather Motion 1:1 (slice1; segments: 1) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((gp_segment_id = 0) AND (a >= 1) AND (a <= 10)) + Optimizer: Pivotal Optimizer (GPORCA) +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where gp_segment_id=0 and a between 1 and 10; +INFO: (slice 1) Dispatch command to SINGLE content + gp_segment_id | a | b +---------------+---+--- + 0 | 2 | 2 + 0 | 3 | 3 + 0 | 4 | 4 + 0 | 7 | 7 + 0 | 8 | 8 +(5 rows) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where b between 1 and 5 and gp_segment_id=2 and a between 1 and 10; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Gather Motion 1:1 (slice1; segments: 1) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((b >= 1) AND (b <= 5) AND (gp_segment_id = 2) AND (a >= 1) AND (a <= 10)) + Optimizer: Pivotal Optimizer (GPORCA) +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where b between 1 and 5 and gp_segment_id=2 and a between 1 and 10; +INFO: (slice 1) Dispatch command to SINGLE content + gp_segment_id | a | b +---------------+---+--- + 2 | 5 | 5 +(1 row) + +--test direct dispatch via gp_segment_id with disjunction +explain (costs off) select * from t_test_dd_via_segid_conj where gp_segment_id=1 or (a=3 and gp_segment_id=2); + QUERY PLAN +---------------------------------------------------------------------------- + Gather Motion 3:1 (slice1; segments: 3) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((gp_segment_id = 1) OR ((a = 3) AND (gp_segment_id = 2))) + Optimizer: Pivotal Optimizer (GPORCA) +(4 rows) + +select * from t_test_dd_via_segid_conj where gp_segment_id=1 or (a=3 and gp_segment_id=2); +INFO: (slice 1) Dispatch command to ALL contents: 0 1 2 + a | b +---+--- + 1 | 1 +(1 row) + +--test direct dispatch with constant distribution column and constant/variable gp_segment_id condition +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id in (0,1); + QUERY PLAN +----------------------------------------------------------------------------------------------------- + Gather Motion 1:1 (slice1; segments: 1) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((a = 3) AND (b >= 1) AND (b <= 10) AND (gp_segment_id = ANY ('{0,1}'::integer[]))) + Optimizer: Pivotal Optimizer (GPORCA) +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id in (0,1); +INFO: (slice 1) Dispatch command to SINGLE content + gp_segment_id | a | b +---------------+---+--- + 0 | 3 | 3 +(1 row) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id <>1; + QUERY PLAN +------------------------------------------------------------------------------- + Gather Motion 1:1 (slice1; segments: 1) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((a = 3) AND (b >= 1) AND (b <= 10) AND (gp_segment_id <> 1)) + Optimizer: Pivotal Optimizer (GPORCA) +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id <>1; +INFO: (slice 1) Dispatch command to SINGLE content + gp_segment_id | a | b +---------------+---+--- + 0 | 3 | 3 +(1 row) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 100 and gp_segment_id =0; + QUERY PLAN +------------------------------------------------------------------------------- + Gather Motion 1:1 (slice1; segments: 1) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((a = 3) AND (b >= 1) AND (b <= 100) AND (gp_segment_id = 0)) + Optimizer: Pivotal Optimizer (GPORCA) +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 100 and gp_segment_id =0; +INFO: (slice 1) Dispatch command to SINGLE content + gp_segment_id | a | b +---------------+---+--- + 0 | 3 | 3 +(1 row) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id <> 0; + QUERY PLAN +--------------------------------------------------------------------------- + Gather Motion 3:1 (slice1; segments: 3) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((a = ANY ('{1,3}'::integer[])) AND (gp_segment_id <> 0)) + Optimizer: Pivotal Optimizer (GPORCA) +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id <> 0; +INFO: (slice 1) Dispatch command to ALL contents: 0 1 2 + gp_segment_id | a | b +---------------+---+--- + 1 | 1 | 1 +(1 row) + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id in (0,1); + QUERY PLAN +------------------------------------------------------------------------------------------------- + Gather Motion 2:1 (slice1; segments: 2) + -> Seq Scan on t_test_dd_via_segid_conj + Filter: ((a = ANY ('{1,3}'::integer[])) AND (gp_segment_id = ANY ('{0,1}'::integer[]))) + Optimizer: Pivotal Optimizer (GPORCA) +(4 rows) + +select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id in (0,1); +INFO: (slice 1) Dispatch command to PARTIAL contents: 0 1 + gp_segment_id | a | b +---------------+---+--- + 1 | 1 | 1 + 0 | 3 | 3 +(2 rows) + -- test direct dispatch via SQLValueFunction and FuncExpr for single row insertion. create table t_sql_value_function1 (a int, b date); NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Cloudberry Database data distribution key for this table. diff --git a/src/test/regress/sql/direct_dispatch.sql b/src/test/regress/sql/direct_dispatch.sql index d9e7b562a0..83199f7883 100644 --- a/src/test/regress/sql/direct_dispatch.sql +++ b/src/test/regress/sql/direct_dispatch.sql @@ -318,6 +318,37 @@ select t1.gp_segment_id, t2.gp_segment_id, * from t_test_dd_via_segid t1, t_test explain (costs off) select gp_segment_id, count(*) from t_test_dd_via_segid group by gp_segment_id; select gp_segment_id, count(*) from t_test_dd_via_segid group by gp_segment_id; +-- test direct dispatch via gp_segment_id qual with conjunction +create table t_test_dd_via_segid_conj(a int, b int); +insert into t_test_dd_via_segid_conj select i,i from generate_series(1, 10)i; + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where gp_segment_id=0 and a between 1 and 10; +select gp_segment_id, * from t_test_dd_via_segid_conj where gp_segment_id=0 and a between 1 and 10; + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where b between 1 and 5 and gp_segment_id=2 and a between 1 and 10; +select gp_segment_id, * from t_test_dd_via_segid_conj where b between 1 and 5 and gp_segment_id=2 and a between 1 and 10; + +--test direct dispatch via gp_segment_id with disjunction + +explain (costs off) select * from t_test_dd_via_segid_conj where gp_segment_id=1 or (a=3 and gp_segment_id=2); +select * from t_test_dd_via_segid_conj where gp_segment_id=1 or (a=3 and gp_segment_id=2); + +--test direct dispatch with constant distribution column and constant/variable gp_segment_id condition +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id in (0,1); +select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id in (0,1); + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id <>1; +select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 10 and gp_segment_id <>1; + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 100 and gp_segment_id =0; +select gp_segment_id, * from t_test_dd_via_segid_conj where a =3 and b between 1 and 100 and gp_segment_id =0; + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id <> 0; +select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id <> 0; + +explain (costs off) select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id in (0,1); +select gp_segment_id, * from t_test_dd_via_segid_conj where a in (1,3) and gp_segment_id in (0,1); + -- test direct dispatch via SQLValueFunction and FuncExpr for single row insertion. create table t_sql_value_function1 (a int, b date); create table t_sql_value_function2 (a date); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
