diff --git a/pkg/planner/core/casetest/enforcempp/testdata/enforce_mpp_suite_out.json b/pkg/planner/core/casetest/enforcempp/testdata/enforce_mpp_suite_out.json index 01cfd9e26b7c1..1e8cf370aaea0 100644 --- a/pkg/planner/core/casetest/enforcempp/testdata/enforce_mpp_suite_out.json +++ b/pkg/planner/core/casetest/enforcempp/testdata/enforce_mpp_suite_out.json @@ -649,11 +649,11 @@ { "SQL": "explain select a from t where t.a not in (select a from s where t.a<1); -- 9. non left join has left conditions", "Plan": [ - "MergeJoin_10 8000.00 root anti semi join, left side:TableReader_23, left key:test.t.a, right key:test.s.a, left cond:lt(test.t.a, 1)", - "├─TableReader_26(Build) 10000.00 root data:TableFullScan_25", - "│ └─TableFullScan_25 10000.00 cop[tikv] table:s keep order:true, stats:pseudo", - "└─TableReader_23(Probe) 10000.00 root data:TableFullScan_22", - " └─TableFullScan_22 10000.00 cop[tikv] table:t keep order:true, stats:pseudo" + "MergeJoin_10 8000.00 root anti semi join, left side:TableReader_24, left key:test.t.a, right key:test.s.a, left cond:lt(test.t.a, 1)", + "├─TableReader_27(Build) 10000.00 root data:TableFullScan_26", + "│ └─TableFullScan_26 10000.00 cop[tikv] table:s keep order:true, stats:pseudo", + "└─TableReader_24(Probe) 10000.00 root data:TableFullScan_23", + " └─TableFullScan_23 10000.00 cop[tikv] table:t keep order:true, stats:pseudo" ], "Warn": [ "MPP mode may be blocked because there is a join that is not `left join` but has left conditions, which is not supported by mpp now, see github.com/pingcap/tidb/issues/26090 for more information.", diff --git a/pkg/planner/core/casetest/physicalplantest/testdata/plan_suite_out.json b/pkg/planner/core/casetest/physicalplantest/testdata/plan_suite_out.json index 4ee0330d587f6..5ab80ad00909f 100644 --- a/pkg/planner/core/casetest/physicalplantest/testdata/plan_suite_out.json +++ b/pkg/planner/core/casetest/physicalplantest/testdata/plan_suite_out.json @@ -1577,15 +1577,15 @@ { "SQL": "explain select * from t1 where exists (select * from t2 where t1.a=t2.b)", "Plan": [ - "TableReader_36 0.80 root MppVersion: 2, data:ExchangeSender_35", - "└─ExchangeSender_35 0.80 mpp[tiflash] ExchangeType: PassThrough", - " └─HashJoin_34 0.80 mpp[tiflash] semi join, left side:Selection_13, equal:[eq(test.t1.a, test.t2.b)]", - " ├─ExchangeReceiver_17(Build) 8.00 mpp[tiflash] ", - " │ └─ExchangeSender_16 8.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST", - " │ └─Selection_15 8.00 mpp[tiflash] not(isnull(test.t2.b))", - " │ └─TableFullScan_14 8.00 mpp[tiflash] table:t2 pushed down filter:empty, keep order:false", - " └─Selection_13(Probe) 1.00 mpp[tiflash] not(isnull(test.t1.a))", - " └─TableFullScan_12 1.00 mpp[tiflash] table:t1 pushed down filter:empty, keep order:false" + "TableReader_37 0.80 root MppVersion: 2, data:ExchangeSender_36", + "└─ExchangeSender_36 0.80 mpp[tiflash] ExchangeType: PassThrough", + " └─HashJoin_35 0.80 mpp[tiflash] semi join, left side:Selection_14, equal:[eq(test.t1.a, test.t2.b)]", + " ├─ExchangeReceiver_18(Build) 8.00 mpp[tiflash] ", + " │ └─ExchangeSender_17 8.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST", + " │ └─Selection_16 8.00 mpp[tiflash] not(isnull(test.t2.b))", + " │ └─TableFullScan_15 8.00 mpp[tiflash] table:t2 pushed down filter:empty, keep order:false", + " └─Selection_14(Probe) 1.00 mpp[tiflash] not(isnull(test.t1.a))", + " └─TableFullScan_13 1.00 mpp[tiflash] table:t1 pushed down filter:empty, keep order:false" ], "Warn": null }, @@ -1607,17 +1607,17 @@ { "SQL": "explain select * from t1 where exists (select * from t2 where t1.a=t2.b)", "Plan": [ - "TableReader_38 0.80 root MppVersion: 2, data:ExchangeSender_37", - "└─ExchangeSender_37 0.80 mpp[tiflash] ExchangeType: PassThrough", - " └─HashJoin_36 0.80 mpp[tiflash] semi join, left side:ExchangeReceiver_15, equal:[eq(test.t1.a, test.t2.b)]", - " ├─ExchangeReceiver_15(Build) 1.00 mpp[tiflash] ", - " │ └─ExchangeSender_14 1.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t1.a, collate: binary]", - " │ └─Selection_13 1.00 mpp[tiflash] not(isnull(test.t1.a))", - " │ └─TableFullScan_12 1.00 mpp[tiflash] table:t1 pushed down filter:empty, keep order:false", - " └─ExchangeReceiver_19(Probe) 8.00 mpp[tiflash] ", - " └─ExchangeSender_18 8.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t2.b, collate: binary]", - " └─Selection_17 8.00 mpp[tiflash] not(isnull(test.t2.b))", - " └─TableFullScan_16 8.00 mpp[tiflash] table:t2 pushed down filter:empty, keep order:false" + "TableReader_39 0.80 root MppVersion: 2, data:ExchangeSender_38", + "└─ExchangeSender_38 0.80 mpp[tiflash] ExchangeType: PassThrough", + " └─HashJoin_37 0.80 mpp[tiflash] semi join, left side:ExchangeReceiver_16, equal:[eq(test.t1.a, test.t2.b)]", + " ├─ExchangeReceiver_16(Build) 1.00 mpp[tiflash] ", + " │ └─ExchangeSender_15 1.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t1.a, collate: binary]", + " │ └─Selection_14 1.00 mpp[tiflash] not(isnull(test.t1.a))", + " │ └─TableFullScan_13 1.00 mpp[tiflash] table:t1 pushed down filter:empty, keep order:false", + " └─ExchangeReceiver_20(Probe) 8.00 mpp[tiflash] ", + " └─ExchangeSender_19 8.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t2.b, collate: binary]", + " └─Selection_18 8.00 mpp[tiflash] not(isnull(test.t2.b))", + " └─TableFullScan_17 8.00 mpp[tiflash] table:t2 pushed down filter:empty, keep order:false" ], "Warn": null } diff --git a/pkg/planner/core/exhaust_physical_plans.go b/pkg/planner/core/exhaust_physical_plans.go index 866428e4137c0..1434536817368 100644 --- a/pkg/planner/core/exhaust_physical_plans.go +++ b/pkg/planner/core/exhaust_physical_plans.go @@ -442,10 +442,8 @@ func getHashJoins(p *logicalop.LogicalJoin, prop *property.PhysicalProperty) (jo if p.SCtx().GetSessionVars().UseHashJoinV2 && joinversion.IsHashJoinV2Supported() && canUseHashJoinV2(p.JoinType, leftJoinKeys, isNullEQ, leftNAJoinKeys) { if !forceLeftToBuild { joins = append(joins, getHashJoin(p, prop, 1, false)) - } else if !forceRightToBuild { - joins = append(joins, getHashJoin(p, prop, 1, true)) - } else { - joins = append(joins, getHashJoin(p, prop, 1, false)) + } + if !forceRightToBuild { joins = append(joins, getHashJoin(p, prop, 1, true)) } } else { diff --git a/tests/integrationtest/r/cte.result b/tests/integrationtest/r/cte.result index 1c9505bae8a5a..4c9e1c8005b84 100644 --- a/tests/integrationtest/r/cte.result +++ b/tests/integrationtest/r/cte.result @@ -581,13 +581,13 @@ c1 c2 insert into t1 values(2, 3); explain select * from t1 where exists(with cte1 as (select c1 from t2 where t2.c2 = t1.c2) select c1 from cte1); id estRows task access object operator info -HashJoin_14 7992.00 root semi join, left side:TableReader_17, equal:[eq(cte.t1.c2, cte.t2.c2)] -├─TableReader_20(Build) 9990.00 root data:Selection_19 -│ └─Selection_19 9990.00 cop[tikv] not(isnull(cte.t2.c2)) -│ └─TableFullScan_18 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -└─TableReader_17(Probe) 9990.00 root data:Selection_16 - └─Selection_16 9990.00 cop[tikv] not(isnull(cte.t1.c2)) - └─TableFullScan_15 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +HashJoin_14 7992.00 root semi join, left side:TableReader_18, equal:[eq(cte.t1.c2, cte.t2.c2)] +├─TableReader_21(Build) 9990.00 root data:Selection_20 +│ └─Selection_20 9990.00 cop[tikv] not(isnull(cte.t2.c2)) +│ └─TableFullScan_19 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader_18(Probe) 9990.00 root data:Selection_17 + └─Selection_17 9990.00 cop[tikv] not(isnull(cte.t1.c2)) + └─TableFullScan_16 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo select * from t1 where exists(with cte1 as (select c1 from t2 where t2.c2 = t1.c2) select c1 from cte1); c1 c2 2 1 @@ -1118,23 +1118,23 @@ SELECT col_4 FROM product_detail ) a; id estRows task access object operator info -Union_210 199600.20 root -├─Projection_211 99800.10 root cte1.table_c.col_4->Column#418 -│ └─CTEFullScan_212 99800.10 root CTE:product_detail data:CTE_4 -└─Projection_213 99800.10 root cte1.table_c.col_4->Column#418 - └─CTEFullScan_214 99800.10 root CTE:product_detail data:CTE_4 +Union_212 199600.20 root +├─Projection_213 99800.10 root cte1.table_c.col_4->Column#418 +│ └─CTEFullScan_214 99800.10 root CTE:product_detail data:CTE_4 +└─Projection_215 99800.10 root cte1.table_c.col_4->Column#418 + └─CTEFullScan_216 99800.10 root CTE:product_detail data:CTE_4 CTE_4 99800.10 root Non-Recursive CTE -└─Projection_172(Seed Part) 99800.10 root cte1.table_c.col_4, 3集合->Column#413 - └─HashJoin_188 99800.10 root left outer join, left side:HashJoin_190, equal:[eq(cte1.table_c.col_4, cte1.table_c.col_4) eq(Column#390, cte1.table_c.col_1)] - ├─TableReader_204(Build) 9980.01 root data:Selection_203 - │ └─Selection_203 9980.01 cop[tikv] not(isnull(cte1.table_c.col_1)), not(isnull(cte1.table_c.col_4)) - │ └─TableFullScan_202 10000.00 cop[tikv] table:a keep order:false, stats:pseudo - └─HashJoin_190(Probe) 80000.00 root CARTESIAN left outer join, left side:HashAgg_196 - ├─CTEFullScan_200(Build) 10.00 root CTE:date_table AS dt data:CTE_0 - └─HashAgg_196(Probe) 8000.00 root group by:cte1.table_c.col_3, cte1.table_c.col_4, funcs:firstrow(cte1.table_c.col_4)->cte1.table_c.col_4 - └─TableReader_197 8000.00 root data:HashAgg_192 - └─HashAgg_192 8000.00 cop[tikv] group by:cte1.table_c.col_3, cte1.table_c.col_4, - └─TableFullScan_195 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +└─Projection_174(Seed Part) 99800.10 root cte1.table_c.col_4, 3集合->Column#413 + └─HashJoin_190 99800.10 root left outer join, left side:HashJoin_192, equal:[eq(cte1.table_c.col_4, cte1.table_c.col_4) eq(Column#390, cte1.table_c.col_1)] + ├─TableReader_206(Build) 9980.01 root data:Selection_205 + │ └─Selection_205 9980.01 cop[tikv] not(isnull(cte1.table_c.col_1)), not(isnull(cte1.table_c.col_4)) + │ └─TableFullScan_204 10000.00 cop[tikv] table:a keep order:false, stats:pseudo + └─HashJoin_192(Probe) 80000.00 root CARTESIAN left outer join, left side:HashAgg_198 + ├─CTEFullScan_202(Build) 10.00 root CTE:date_table AS dt data:CTE_0 + └─HashAgg_198(Probe) 8000.00 root group by:cte1.table_c.col_3, cte1.table_c.col_4, funcs:firstrow(cte1.table_c.col_4)->cte1.table_c.col_4 + └─TableReader_199 8000.00 root data:HashAgg_194 + └─HashAgg_194 8000.00 cop[tikv] group by:cte1.table_c.col_3, cte1.table_c.col_4, + └─TableFullScan_197 10000.00 cop[tikv] table:t keep order:false, stats:pseudo CTE_0 10.00 root Non-Recursive CTE └─Apply_95(Seed Part) 10.00 root CARTESIAN left outer join, left side:Apply_97 ├─Apply_97(Build) 10.00 root CARTESIAN left outer join, left side:Apply_99 @@ -1145,38 +1145,38 @@ CTE_0 10.00 root Non-Recursive CTE │ │ │ │ └─TableFullScan_102 10000.00 cop[tikv] table:d keep order:false, stats:pseudo │ │ │ └─StreamAgg_106(Probe) 10.00 root funcs:max(cte1.table_c.col_1)->Column#159 │ │ │ └─TopN_109 10.00 root cte1.table_c.col_1:desc, offset:0, count:1 - │ │ │ └─HashJoin_114 63936.00 root semi join, left side:Projection_115, equal:[eq(Column#423, Column#424)] - │ │ │ ├─Projection_119(Build) 80000.00 root cast(cte1.table_d.col_1, double BINARY)->Column#424 - │ │ │ │ └─TableReader_122 80000.00 root data:Selection_121 - │ │ │ │ └─Selection_121 80000.00 cop[tikv] eq(cast(cte1.table_d.col_2, double BINARY), 1) - │ │ │ │ └─TableFullScan_120 100000.00 cop[tikv] table:d keep order:false, stats:pseudo - │ │ │ └─Projection_115(Probe) 79920.00 root cte1.table_c.col_1, cast(cte1.table_c.col_1, double BINARY)->Column#423 - │ │ │ └─IndexReader_118 79920.00 root index:Selection_117 - │ │ │ └─Selection_117 79920.00 cop[tikv] le(cte1.table_c.col_1, concat(cast(year(cast(date_sub(cte1.table_d.col_1, 1, "YEAR"), datetime(6) BINARY)), var_string(20)), "1231")) - │ │ │ └─IndexFullScan_116 99900.00 cop[tikv] table:a, index:index_col_1_3(col_1, col_3) keep order:false, stats:pseudo - │ │ └─StreamAgg_124(Probe) 10.00 root funcs:max(cte1.table_a.col_1)->Column#208 - │ │ └─TopN_127 10.00 root cte1.table_a.col_1:desc, offset:0, count:1 - │ │ └─HashJoin_132 63936.00 root semi join, left side:Projection_133, equal:[eq(Column#429, Column#430)] - │ │ ├─Projection_137(Build) 80000.00 root cast(cte1.table_d.col_1, double BINARY)->Column#430 - │ │ │ └─TableReader_140 80000.00 root data:Selection_139 - │ │ │ └─Selection_139 80000.00 cop[tikv] eq(cast(cte1.table_d.col_2, double BINARY), 1) - │ │ │ └─TableFullScan_138 100000.00 cop[tikv] table:d keep order:false, stats:pseudo - │ │ └─Projection_133(Probe) 79920.00 root cte1.table_a.col_1, cast(cte1.table_a.col_1, double BINARY)->Column#429 - │ │ └─IndexReader_136 79920.00 root index:Selection_135 - │ │ └─Selection_135 79920.00 cop[tikv] le(cte1.table_a.col_1, concat(cast(year(cast(date_sub(cte1.table_d.col_1, 1, "YEAR"), datetime(6) BINARY)), var_string(20)), "1231")) - │ │ └─IndexFullScan_134 99900.00 cop[tikv] table:a, index:index_col_1(col_1) keep order:false, stats:pseudo - │ └─StreamAgg_142(Probe) 10.00 root funcs:max(cte1.table_c.col_1)->Column#230 - │ └─Limit_146 10.00 root offset:0, count:1 - │ └─IndexReader_155 10.00 root index:Limit_154 - │ └─Limit_154 10.00 cop[tikv] offset:0, count:1 - │ └─Selection_153 10.00 cop[tikv] le(cast(cte1.table_c.col_1, double BINARY), cast(cte1.table_d.col_1, double BINARY)) - │ └─IndexFullScan_152 12.50 cop[tikv] table:table_c, index:index_col_1_3(col_1, col_3) keep order:true, desc, stats:pseudo - └─StreamAgg_157(Probe) 10.00 root funcs:max(cte1.table_a.col_1)->Column#254 - └─Limit_161 10.00 root offset:0, count:1 - └─IndexReader_170 10.00 root index:Limit_169 - └─Limit_169 10.00 cop[tikv] offset:0, count:1 - └─Selection_168 10.00 cop[tikv] le(cast(cte1.table_a.col_1, double BINARY), cast(cte1.table_d.col_1, double BINARY)) - └─IndexFullScan_167 12.50 cop[tikv] table:table_a, index:index_col_1(col_1) keep order:true, desc, stats:pseudo + │ │ │ └─HashJoin_114 63936.00 root semi join, left side:Projection_116, equal:[eq(Column#423, Column#424)] + │ │ │ ├─Projection_120(Build) 80000.00 root cast(cte1.table_d.col_1, double BINARY)->Column#424 + │ │ │ │ └─TableReader_123 80000.00 root data:Selection_122 + │ │ │ │ └─Selection_122 80000.00 cop[tikv] eq(cast(cte1.table_d.col_2, double BINARY), 1) + │ │ │ │ └─TableFullScan_121 100000.00 cop[tikv] table:d keep order:false, stats:pseudo + │ │ │ └─Projection_116(Probe) 79920.00 root cte1.table_c.col_1, cast(cte1.table_c.col_1, double BINARY)->Column#423 + │ │ │ └─IndexReader_119 79920.00 root index:Selection_118 + │ │ │ └─Selection_118 79920.00 cop[tikv] le(cte1.table_c.col_1, concat(cast(year(cast(date_sub(cte1.table_d.col_1, 1, "YEAR"), datetime(6) BINARY)), var_string(20)), "1231")) + │ │ │ └─IndexFullScan_117 99900.00 cop[tikv] table:a, index:index_col_1_3(col_1, col_3) keep order:false, stats:pseudo + │ │ └─StreamAgg_125(Probe) 10.00 root funcs:max(cte1.table_a.col_1)->Column#208 + │ │ └─TopN_128 10.00 root cte1.table_a.col_1:desc, offset:0, count:1 + │ │ └─HashJoin_133 63936.00 root semi join, left side:Projection_135, equal:[eq(Column#429, Column#430)] + │ │ ├─Projection_139(Build) 80000.00 root cast(cte1.table_d.col_1, double BINARY)->Column#430 + │ │ │ └─TableReader_142 80000.00 root data:Selection_141 + │ │ │ └─Selection_141 80000.00 cop[tikv] eq(cast(cte1.table_d.col_2, double BINARY), 1) + │ │ │ └─TableFullScan_140 100000.00 cop[tikv] table:d keep order:false, stats:pseudo + │ │ └─Projection_135(Probe) 79920.00 root cte1.table_a.col_1, cast(cte1.table_a.col_1, double BINARY)->Column#429 + │ │ └─IndexReader_138 79920.00 root index:Selection_137 + │ │ └─Selection_137 79920.00 cop[tikv] le(cte1.table_a.col_1, concat(cast(year(cast(date_sub(cte1.table_d.col_1, 1, "YEAR"), datetime(6) BINARY)), var_string(20)), "1231")) + │ │ └─IndexFullScan_136 99900.00 cop[tikv] table:a, index:index_col_1(col_1) keep order:false, stats:pseudo + │ └─StreamAgg_144(Probe) 10.00 root funcs:max(cte1.table_c.col_1)->Column#230 + │ └─Limit_148 10.00 root offset:0, count:1 + │ └─IndexReader_157 10.00 root index:Limit_156 + │ └─Limit_156 10.00 cop[tikv] offset:0, count:1 + │ └─Selection_155 10.00 cop[tikv] le(cast(cte1.table_c.col_1, double BINARY), cast(cte1.table_d.col_1, double BINARY)) + │ └─IndexFullScan_154 12.50 cop[tikv] table:table_c, index:index_col_1_3(col_1, col_3) keep order:true, desc, stats:pseudo + └─StreamAgg_159(Probe) 10.00 root funcs:max(cte1.table_a.col_1)->Column#254 + └─Limit_163 10.00 root offset:0, count:1 + └─IndexReader_172 10.00 root index:Limit_171 + └─Limit_171 10.00 cop[tikv] offset:0, count:1 + └─Selection_170 10.00 cop[tikv] le(cast(cte1.table_a.col_1, double BINARY), cast(cte1.table_d.col_1, double BINARY)) + └─IndexFullScan_169 12.50 cop[tikv] table:table_a, index:index_col_1(col_1) keep order:true, desc, stats:pseudo WITH date_table AS ( SELECT d.col_1 AS date, diff --git a/tests/integrationtest/r/naaj.result b/tests/integrationtest/r/naaj.result index 2be21d95768f9..60f452a36d4ff 100644 --- a/tests/integrationtest/r/naaj.result +++ b/tests/integrationtest/r/naaj.result @@ -404,9 +404,9 @@ HashJoin_9 10000.00 root anti left outer semi join, left side:TableReader_11, e └─TableFullScan_10 10000.00 cop[tikv] table:naaj_A keep order:false, stats:pseudo explain select * from naaj_A where (a+1,b*2) not in (select a, b=1 from naaj_B where naaj_A.a = naaj_B.a); id estRows task access object operator info -HashJoin_9 8000.00 root anti semi join, left side:TableReader_11, equal:[eq(naaj.naaj_a.a, naaj.naaj_b.a)], other cond:eq(mul(naaj.naaj_a.b, 2), eq(naaj.naaj_b.b, 1)), eq(plus(naaj.naaj_a.a, 1), naaj.naaj_b.a) -├─TableReader_13(Build) 10000.00 root data:TableFullScan_12 -│ └─TableFullScan_12 10000.00 cop[tikv] table:naaj_B keep order:false, stats:pseudo -└─TableReader_11(Probe) 10000.00 root data:TableFullScan_10 - └─TableFullScan_10 10000.00 cop[tikv] table:naaj_A keep order:false, stats:pseudo +HashJoin_9 8000.00 root anti semi join, left side:TableReader_12, equal:[eq(naaj.naaj_a.a, naaj.naaj_b.a)], other cond:eq(mul(naaj.naaj_a.b, 2), eq(naaj.naaj_b.b, 1)), eq(plus(naaj.naaj_a.a, 1), naaj.naaj_b.a) +├─TableReader_14(Build) 10000.00 root data:TableFullScan_13 +│ └─TableFullScan_13 10000.00 cop[tikv] table:naaj_B keep order:false, stats:pseudo +└─TableReader_12(Probe) 10000.00 root data:TableFullScan_11 + └─TableFullScan_11 10000.00 cop[tikv] table:naaj_A keep order:false, stats:pseudo set @@session.tidb_enable_null_aware_anti_join=0; diff --git a/tests/integrationtest/r/planner/core/casetest/integration.result b/tests/integrationtest/r/planner/core/casetest/integration.result index 84f5a0b9efa1b..12f95552544ad 100644 --- a/tests/integrationtest/r/planner/core/casetest/integration.result +++ b/tests/integrationtest/r/planner/core/casetest/integration.result @@ -1423,27 +1423,27 @@ set @@tidb_skip_missing_partition_stats = off; set @@tidb_opt_fix_control = ""; explain select /*+ TIDB_INLJ(t2_part@sel_2) */ * from t1 where t1.b<10 and not exists (select 1 from t2_part where t1.a=t2_part.a and t2_part.b<20); id estRows task access object operator info -HashJoin_19 2658.67 root anti semi join, left side:TableReader_22, equal:[eq(planner__core__casetest__integration.t1.a, planner__core__casetest__integration.t2_part.a)] -├─PartitionUnion_23(Build) 13293.33 root -│ ├─TableReader_31 3323.33 root data:Projection_25 -│ │ └─Projection_25 3323.33 cop[tikv] planner__core__casetest__integration.t2_part.a -│ │ └─Selection_30 3323.33 cop[tikv] lt(planner__core__casetest__integration.t2_part.b, 20) -│ │ └─TableFullScan_29 10000.00 cop[tikv] table:t2_part, partition:p0 keep order:false, stats:pseudo -│ ├─TableReader_39 3323.33 root data:Projection_33 -│ │ └─Projection_33 3323.33 cop[tikv] planner__core__casetest__integration.t2_part.a -│ │ └─Selection_38 3323.33 cop[tikv] lt(planner__core__casetest__integration.t2_part.b, 20) -│ │ └─TableFullScan_37 10000.00 cop[tikv] table:t2_part, partition:p1 keep order:false, stats:pseudo -│ ├─TableReader_47 3323.33 root data:Projection_41 -│ │ └─Projection_41 3323.33 cop[tikv] planner__core__casetest__integration.t2_part.a -│ │ └─Selection_46 3323.33 cop[tikv] lt(planner__core__casetest__integration.t2_part.b, 20) -│ │ └─TableFullScan_45 10000.00 cop[tikv] table:t2_part, partition:p2 keep order:false, stats:pseudo -│ └─TableReader_55 3323.33 root data:Projection_49 -│ └─Projection_49 3323.33 cop[tikv] planner__core__casetest__integration.t2_part.a -│ └─Selection_54 3323.33 cop[tikv] lt(planner__core__casetest__integration.t2_part.b, 20) -│ └─TableFullScan_53 10000.00 cop[tikv] table:t2_part, partition:p3 keep order:false, stats:pseudo -└─TableReader_22(Probe) 3323.33 root data:Selection_21 - └─Selection_21 3323.33 cop[tikv] lt(planner__core__casetest__integration.t1.b, 10) - └─TableFullScan_20 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +HashJoin_19 2658.67 root anti semi join, left side:TableReader_23, equal:[eq(planner__core__casetest__integration.t1.a, planner__core__casetest__integration.t2_part.a)] +├─PartitionUnion_24(Build) 13293.33 root +│ ├─TableReader_32 3323.33 root data:Projection_26 +│ │ └─Projection_26 3323.33 cop[tikv] planner__core__casetest__integration.t2_part.a +│ │ └─Selection_31 3323.33 cop[tikv] lt(planner__core__casetest__integration.t2_part.b, 20) +│ │ └─TableFullScan_30 10000.00 cop[tikv] table:t2_part, partition:p0 keep order:false, stats:pseudo +│ ├─TableReader_40 3323.33 root data:Projection_34 +│ │ └─Projection_34 3323.33 cop[tikv] planner__core__casetest__integration.t2_part.a +│ │ └─Selection_39 3323.33 cop[tikv] lt(planner__core__casetest__integration.t2_part.b, 20) +│ │ └─TableFullScan_38 10000.00 cop[tikv] table:t2_part, partition:p1 keep order:false, stats:pseudo +│ ├─TableReader_48 3323.33 root data:Projection_42 +│ │ └─Projection_42 3323.33 cop[tikv] planner__core__casetest__integration.t2_part.a +│ │ └─Selection_47 3323.33 cop[tikv] lt(planner__core__casetest__integration.t2_part.b, 20) +│ │ └─TableFullScan_46 10000.00 cop[tikv] table:t2_part, partition:p2 keep order:false, stats:pseudo +│ └─TableReader_56 3323.33 root data:Projection_50 +│ └─Projection_50 3323.33 cop[tikv] planner__core__casetest__integration.t2_part.a +│ └─Selection_55 3323.33 cop[tikv] lt(planner__core__casetest__integration.t2_part.b, 20) +│ └─TableFullScan_54 10000.00 cop[tikv] table:t2_part, partition:p3 keep order:false, stats:pseudo +└─TableReader_23(Probe) 3323.33 root data:Selection_22 + └─Selection_22 3323.33 cop[tikv] lt(planner__core__casetest__integration.t1.b, 10) + └─TableFullScan_21 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo Level Code Message Warning 1105 disable dynamic pruning due to t2_part has no global stats Warning 1815 Optimizer Hint /*+ INL_JOIN(t2_part) */ or /*+ TIDB_INLJ(t2_part) */ is inapplicable diff --git a/tests/integrationtest/r/planner/core/casetest/physicalplantest/physical_plan.result b/tests/integrationtest/r/planner/core/casetest/physicalplantest/physical_plan.result index d4d06658a4364..4438e56437820 100644 --- a/tests/integrationtest/r/planner/core/casetest/physicalplantest/physical_plan.result +++ b/tests/integrationtest/r/planner/core/casetest/physicalplantest/physical_plan.result @@ -2909,12 +2909,12 @@ Warning 1815 NO_DECORRELATE() and SEMI_JOIN_REWRITE() are in conflict. Both will explain format = 'brief' select t1.a from t1 where t1.a in (select t2.b from t2 where t2.a = t1.b); id estRows task access object operator info HashJoin 7984.01 root semi join, left side:TableReader, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.b)] -├─TableReader(Build) 9990.00 root data:Selection -│ └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) -│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -└─TableReader(Probe) 9980.01 root data:Selection - └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.b)) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +├─TableReader(Build) 9980.01 root data:Selection +│ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.b)) +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo select t1.a from t1 where t1.a in (select t2.b from t2 where t2.a = t1.b); a 1 diff --git a/tests/integrationtest/r/tpch.result b/tests/integrationtest/r/tpch.result index 905849349a4f5..cb9d2891d2766 100644 --- a/tests/integrationtest/r/tpch.result +++ b/tests/integrationtest/r/tpch.result @@ -1294,8 +1294,8 @@ Sort 1.00 root Column#31 └─HashAgg 1.00 root group by:Column#36, funcs:count(1)->Column#32, funcs:sum(Column#35)->Column#33, funcs:firstrow(Column#36)->Column#31 └─Projection 0.64 root tpch50.customer.c_acctbal->Column#35, substring(tpch50.customer.c_phone, 1, 2)->Column#36 └─HashJoin 0.64 root anti semi join, left side:TableReader, equal:[eq(tpch50.customer.c_custkey, tpch50.orders.o_custkey)] - ├─TableReader(Build) 75000000.00 root data:TableFullScan - │ └─TableFullScan 75000000.00 cop[tikv] table:orders keep order:false - └─TableReader(Probe) 0.80 root data:Selection - └─Selection 0.80 cop[tikv] gt(tpch50.customer.c_acctbal, NULL), in(substring(tpch50.customer.c_phone, 1, 2), "20", "40", "22", "30", "39", "42", "21") - └─TableFullScan 7500000.00 cop[tikv] table:customer keep order:false + ├─TableReader(Build) 0.80 root data:Selection + │ └─Selection 0.80 cop[tikv] gt(tpch50.customer.c_acctbal, NULL), in(substring(tpch50.customer.c_phone, 1, 2), "20", "40", "22", "30", "39", "42", "21") + │ └─TableFullScan 7500000.00 cop[tikv] table:customer keep order:false + └─TableReader(Probe) 75000000.00 root data:TableFullScan + └─TableFullScan 75000000.00 cop[tikv] table:orders keep order:false