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 899c6f8922c1d..6c4047489355a 100644 --- a/pkg/planner/core/casetest/physicalplantest/testdata/plan_suite_out.json +++ b/pkg/planner/core/casetest/physicalplantest/testdata/plan_suite_out.json @@ -2171,11 +2171,11 @@ }, { "SQL": "select a from t where c_str like ''", - "Best": "IndexReader(Index(t.c_d_e_str)[[\"\",\"\"]])->Projection" + "Best": "IndexReader(Index(t.c_d_e_str)[[\"\",\"\"]]->Sel([like(test.t.c_str, , 92)]))->Projection" }, { "SQL": "select a from t where c_str like 'abc'", - "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc\",\"abc\"]])->Projection" + "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc\",\"abc\"]]->Sel([like(test.t.c_str, abc, 92)]))->Projection" }, { "SQL": "select a from t where c_str not like 'abc'", @@ -2191,7 +2191,7 @@ }, { "SQL": "select a from t where c_str like 'abc%'", - "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc\",\"abd\")])->Projection" + "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc\",\"abd\")]->Sel([like(test.t.c_str, abc%, 92)]))->Projection" }, { "SQL": "select a from t where c_str like 'abc_'", @@ -2203,23 +2203,23 @@ }, { "SQL": "select a from t where c_str like 'abc\\_' escape ''", - "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc_\"]])->Projection" + "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc_\"]]->Sel([like(test.t.c_str, abc\\_, 92)]))->Projection" }, { "SQL": "select a from t where c_str like 'abc\\_'", - "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc_\"]])->Projection" + "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc_\"]]->Sel([like(test.t.c_str, abc\\_, 92)]))->Projection" }, { "SQL": "select a from t where c_str like 'abc\\\\_'", - "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc_\"]])->Projection" + "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc_\"]]->Sel([like(test.t.c_str, abc\\_, 92)]))->Projection" }, { "SQL": "select a from t where c_str like 'abc\\_%'", - "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc`\")])->Projection" + "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc`\")]->Sel([like(test.t.c_str, abc\\_%, 92)]))->Projection" }, { "SQL": "select a from t where c_str like 'abc=_%' escape '='", - "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc`\")])->Projection" + "Best": "IndexReader(Index(t.c_d_e_str)[[\"abc_\",\"abc`\")]->Sel([like(test.t.c_str, abc=_%, 61)]))->Projection" }, { "SQL": "select a from t where c_str like 'abc\\__'", @@ -2227,7 +2227,7 @@ }, { "SQL": "select a from t where c_str like 123", - "Best": "IndexReader(Index(t.c_d_e_str)[[\"123\",\"123\"]])->Projection" + "Best": "IndexReader(Index(t.c_d_e_str)[[\"123\",\"123\"]]->Sel([like(test.t.c_str, 123, 92)]))->Projection" }, { "SQL": "select a from t where c = 1.9 and d > 3", diff --git a/pkg/util/ranger/checker.go b/pkg/util/ranger/checker.go index 7d769a029b2fd..5adc44c352e24 100644 --- a/pkg/util/ranger/checker.go +++ b/pkg/util/ranger/checker.go @@ -17,6 +17,7 @@ package ranger import ( "github.com/pingcap/tidb/pkg/expression" "github.com/pingcap/tidb/pkg/parser/ast" + "github.com/pingcap/tidb/pkg/parser/charset" "github.com/pingcap/tidb/pkg/parser/mysql" "github.com/pingcap/tidb/pkg/types" "github.com/pingcap/tidb/pkg/util/collate" @@ -166,11 +167,22 @@ func (c *conditionChecker) checkLikeFunc(scalar *expression.ScalarFunction) (isA if err != nil { return false, true } + likeFuncReserve := !c.isFullLengthColumn() + + // Different from `=`, trailing spaces are always significant, and can't be ignored in `like`. + // In tidb's implementation, for PAD SPACE collations, the trailing spaces are removed in the index key. So we are + // unable to distinguish 'xxx' from 'xxx ' by a single index range scan, and we may read more data than needed by + // the `like` function. Therefore, a Selection is needed to filter the data. + // Since all collations, except for binary, implemented in tidb are PAD SPACE collations for now, we use a simple + // collation != binary check here. + if collation != charset.CollationBin { + likeFuncReserve = true + } + if len(patternStr) == 0 { - return true, !c.isFullLengthColumn() + return true, likeFuncReserve } escape := byte(scalar.GetArgs()[2].(*expression.Constant).Value.GetInt64()) - likeFuncReserve := !c.isFullLengthColumn() for i := 0; i < len(patternStr); i++ { if patternStr[i] == escape { i++ diff --git a/pkg/util/ranger/ranger_test.go b/pkg/util/ranger/ranger_test.go index 71a4552ae491c..17397b2a16986 100644 --- a/pkg/util/ranger/ranger_test.go +++ b/pkg/util/ranger/ranger_test.go @@ -1098,7 +1098,7 @@ create table t( indexPos: 0, exprStr: `a LIKE 'abc%'`, accessConds: `[like(test.t.a, abc%, 92)]`, - filterConds: "[]", + filterConds: "[like(test.t.a, abc%, 92)]", resultStr: "[[\"abc\",\"abd\")]", }, { @@ -1112,14 +1112,14 @@ create table t( indexPos: 0, exprStr: "a LIKE 'abc'", accessConds: "[like(test.t.a, abc, 92)]", - filterConds: "[]", + filterConds: "[like(test.t.a, abc, 92)]", resultStr: "[[\"abc\",\"abc\"]]", }, { indexPos: 0, exprStr: `a LIKE "ab\_c"`, accessConds: "[like(test.t.a, ab\\_c, 92)]", - filterConds: "[]", + filterConds: "[like(test.t.a, ab\\_c, 92)]", resultStr: "[[\"ab_c\",\"ab_c\"]]", }, { @@ -1133,21 +1133,21 @@ create table t( indexPos: 0, exprStr: `a LIKE '\%a'`, accessConds: "[like(test.t.a, \\%a, 92)]", - filterConds: "[]", + filterConds: "[like(test.t.a, \\%a, 92)]", resultStr: `[["%a","%a"]]`, }, { indexPos: 0, exprStr: `a LIKE "\\"`, accessConds: "[like(test.t.a, \\, 92)]", - filterConds: "[]", + filterConds: "[like(test.t.a, \\, 92)]", resultStr: "[[\"\\\\\",\"\\\\\"]]", }, { indexPos: 0, exprStr: `a LIKE "\\\\a%"`, accessConds: `[like(test.t.a, \\a%, 92)]`, - filterConds: "[]", + filterConds: "[like(test.t.a, \\\\a%, 92)]", resultStr: "[[\"\\\\a\",\"\\\\b\")]", }, { diff --git a/tests/integrationtest/r/explain_generate_column_substitute.result b/tests/integrationtest/r/explain_generate_column_substitute.result index 18697ae37d263..fe82e00969f7d 100644 --- a/tests/integrationtest/r/explain_generate_column_substitute.result +++ b/tests/integrationtest/r/explain_generate_column_substitute.result @@ -415,7 +415,8 @@ id estRows task access object operator info StreamAgg 1.00 root funcs:count(Column#6)->Column#4 └─IndexReader 1.00 root index:StreamAgg └─StreamAgg 1.00 cop[tikv] funcs:count(1)->Column#6 - └─IndexRangeScan 250.00 cop[tikv] table:tbl1, index:expression_index(md5(`s`)) range:["02e74f10e0327ad868d138f2b4fdd6f","02e74f10e0327ad868d138f2b4fdd6g"), keep order:false, stats:pseudo + └─Selection 250.00 cop[tikv] like(md5(cast(explain_generate_column_substitute.tbl1.s, var_string(20))), "02e74f10e0327ad868d138f2b4fdd6f%", 92) + └─IndexRangeScan 250.00 cop[tikv] table:tbl1, index:expression_index(md5(`s`)) range:["02e74f10e0327ad868d138f2b4fdd6f","02e74f10e0327ad868d138f2b4fdd6g"), keep order:false, stats:pseudo select count(*) from tbl1 use index() where md5(s) like '02e74f10e0327ad868d138f2b4fdd6f%'; count(*) 64 diff --git a/tests/integrationtest/r/planner/core/casetest/physicalplantest/physical_plan.result b/tests/integrationtest/r/planner/core/casetest/physicalplantest/physical_plan.result new file mode 100644 index 0000000000000..541e196db8f36 --- /dev/null +++ b/tests/integrationtest/r/planner/core/casetest/physicalplantest/physical_plan.result @@ -0,0 +1,3755 @@ +drop table if exists t1, t2; +create table t1(a int primary key, b int not null); +create table t2(a int primary key, b int not null); +insert into t1 values(1,1),(2,2); +insert into t2 values(1,1),(2,1); +explain format = 'brief' select /*+ inl_merge_join(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +IndexMergeJoin 12500.00 root left outer join, inner:TableReader, outer key:planner__core__casetest__physicalplantest__physical_plan.t1.a, inner key:planner__core__casetest__physicalplantest__physical_plan.t2.a, other cond:eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableRangeScan + └─TableRangeScan 10000.00 cop[tikv] table:t2 range: decided by [planner__core__casetest__physicalplantest__physical_plan.t1.a], keep order:true, stats:pseudo +select /*+ inl_merge_join(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +2 NULL +explain format = 'brief' select /*+ inl_hash_join(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +IndexHashJoin 12500.00 root left outer join, inner:TableReader, outer key:planner__core__casetest__physicalplantest__physical_plan.t1.a, inner key:planner__core__casetest__physicalplantest__physical_plan.t2.a, equal cond:eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a), eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableRangeScan + └─TableRangeScan 10000.00 cop[tikv] table:t2 range: decided by [planner__core__casetest__physicalplantest__physical_plan.t1.a], keep order:false, stats:pseudo +select /*+ inl_hash_join(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +2 NULL +explain format = 'brief' select /*+ inl_join(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +IndexJoin 12500.00 root left outer join, inner:TableReader, outer key:planner__core__casetest__physicalplantest__physical_plan.t1.a, inner key:planner__core__casetest__physicalplantest__physical_plan.t2.a, equal cond:eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a), eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableRangeScan + └─TableRangeScan 10000.00 cop[tikv] table:t2 range: decided by [planner__core__casetest__physicalplantest__physical_plan.t1.a], keep order:false, stats:pseudo +select /*+ inl_join(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +2 NULL +explain format = 'brief' select /*+ hash_join(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +2 NULL +drop table if exists t1, t2, t3; +create table t1(a int(11) DEFAULT NULL, b int(11) DEFAULT NULL, UNIQUE KEY idx_a (a)); +create table t2(a int(11) DEFAULT NULL, b int(11) DEFAULT NULL); +create table t3(a int(11) DEFAULT NULL, b int(11) DEFAULT NULL, c int(11) DEFAULT NULL, UNIQUE KEY idx_abc (a, b, c)); +explain format = 'brief' select a from t2 where t2.a < (select t1.a from t1 where t1.a = t2.a); +id estRows task access object operator info +HashJoin 9990.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.a)], other cond:lt(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.a) +├─IndexReader(Build) 7992.00 root index:Selection +│ └─Selection 7992.00 cop[tikv] lt(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t1.a) +│ └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:false, stats:pseudo +└─TableReader(Probe) 7992.00 root data:Selection + └─Selection 7992.00 cop[tikv] lt(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t2.a), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)) + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select a from t2 where t2.a < (select t1.a from t1 where t1.a = t2.a); +a +explain format = 'brief' select a from t2 where t2.a < (select t1.a from t1 where t1.b = t2.b and t1.a is null); +id estRows task access object operator info +Projection 9990.00 root planner__core__casetest__physicalplantest__physical_plan.t2.a +└─Apply 9990.00 root CARTESIAN inner join, other cond:lt(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.a) + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─Selection(Probe) 7992.00 root not(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.a)) + └─MaxOneRow 9990.00 root + └─IndexLookUp 9.99 root + ├─IndexRangeScan(Build) 9990.00 cop[tikv] table:t1, index:idx_a(a) range:[NULL,NULL], keep order:false, stats:pseudo + └─Selection(Probe) 9.99 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) + └─TableRowIDScan 9990.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select a from t2 where t2.a < (select t1.a from t1 where t1.b = t2.b and t1.a is null); +a +explain format = 'brief' select a from t2 where t2.a < (select t3.a from t3 where t3.a = t2.a); +id estRows task access object operator info +Projection 9990.00 root planner__core__casetest__physicalplantest__physical_plan.t2.a +└─Apply 9990.00 root CARTESIAN inner join, other cond:lt(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t3.a) + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─Selection(Probe) 7992.00 root not(isnull(planner__core__casetest__physicalplantest__physical_plan.t3.a)) + └─MaxOneRow 9990.00 root + └─IndexReader 19980.00 root index:IndexRangeScan + └─IndexRangeScan 19980.00 cop[tikv] table:t3, index:idx_abc(a, b, c) range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.t3.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)], keep order:false, stats:pseudo +select a from t2 where t2.a < (select t3.a from t3 where t3.a = t2.a); +a +set tidb_cost_model_version=2; +drop table if exists t, tt; +create table t (a int primary key, b int, index idx(a)); +create table tt (a int primary key) partition by range (a) (partition p0 values less than (100), partition p1 values less than (200)); +set @@tidb_partition_prune_mode='static'; +begin; +insert into t values(1, 1); +explain format = 'brief' select /*+ TIDB_INLJ(t2) */ * from t t1, t t2 where t1.a = t2.a; +id estRows task access object operator info +IndexJoin 12500.00 root inner join, inner:UnionScan, outer key:planner__core__casetest__physicalplantest__physical_plan.t.a, inner key:planner__core__casetest__physicalplantest__physical_plan.t.a, equal cond:eq(planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.a) +├─UnionScan(Build) 10000.00 root +│ └─TableReader 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─UnionScan(Probe) 10000.00 root + └─TableReader 10000.00 root data:TableRangeScan + └─TableRangeScan 10000.00 cop[tikv] table:t2 range: decided by [planner__core__casetest__physicalplantest__physical_plan.t.a], keep order:false, stats:pseudo +rollback; +begin; +insert into t values(1, 1); +explain format = 'brief' select /*+ TIDB_INLJ(t2) */ * from t t1, t t2 where t1.a = t2.b; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.b, planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.b +└─HashJoin 12487.50 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t.b, planner__core__casetest__physicalplantest__physical_plan.t.a)] + ├─UnionScan(Build) 9990.00 root not(isnull(planner__core__casetest__physicalplantest__physical_plan.t.b)) + │ └─TableReader 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─UnionScan(Probe) 10000.00 root + └─TableReader 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +rollback; +begin; +insert into t values(1, 1); +explain format = 'brief' select /*+ TIDB_INLJ(t2) */ t1.a , t2.b from t t1, t t2 where t1.a = t2.b; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.b +└─HashJoin 12487.50 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t.b, planner__core__casetest__physicalplantest__physical_plan.t.a)] + ├─UnionScan(Build) 10000.00 root + │ └─TableReader 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─UnionScan(Probe) 9990.00 root not(isnull(planner__core__casetest__physicalplantest__physical_plan.t.b)) + └─TableReader 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t.b)) + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +rollback; +begin; +insert into tt values(1); +explain format = 'brief' select /*+ TIDB_INLJ(t2) */ * from tt t1, tt t2 where t1.a = t2.a; +id estRows task access object operator info +HashJoin 25000.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.tt.a, planner__core__casetest__physicalplantest__physical_plan.tt.a)] +├─PartitionUnion(Build) 20000.00 root +│ ├─UnionScan 10000.00 root +│ │ └─TableReader 10000.00 root data:TableFullScan +│ │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +│ └─UnionScan 10000.00 root +│ └─TableReader 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +└─PartitionUnion(Probe) 20000.00 root + ├─UnionScan 10000.00 root + │ └─TableReader 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1, partition:p0 keep order:false, stats:pseudo + └─UnionScan 10000.00 root + └─TableReader 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1, partition:p1 keep order:false, stats:pseudo +rollback; +set tidb_cost_model_version=DEFAULT; +set @@tidb_partition_prune_mode=DEFAULT; +drop table if exists t1, t2; +create table t1 (c_int int, c_str varchar(40), primary key (c_int)); +create table t2 (c_int int, c_str varchar(40), primary key (c_int)); +insert into t1 (`c_int`, `c_str`) values (11, 'keen williamson'), (10, 'gracious hermann'); +insert into t2 (`c_int`, `c_str`) values (10, 'gracious hermann'); +begin; +insert into t2 values (11, 'amazing merkle'); +insert into t2 values (12, 'amazing merkle'); +explain format = 'brief' select /*+ MERGE_JOIN(t1,t2) */ * from t1, t2 where t1.c_int = t2.c_int and t1.c_int = t2.c_int order by t1.c_int, t2.c_str; +id estRows task access object operator info +Sort 12500.00 root planner__core__casetest__physicalplantest__physical_plan.t1.c_int, planner__core__casetest__physicalplantest__physical_plan.t2.c_str +└─MergeJoin 12500.00 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.c_int, right key:planner__core__casetest__physicalplantest__physical_plan.t2.c_int + ├─UnionScan(Build) 10000.00 root + │ └─TableReader 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +rollback; +set tidb_cost_model_version=2; +drop table if exists tn; +create table tn(a int, b int, c int, d int, key (a, b, c, d)); +set tidb_opt_limit_push_down_threshold=0; +explain format = 'brief' select /*+ LIMIT_TO_COP() */ * from tn where a = 1 and b > 10 and b < 20 and c > 50 order by d limit 1; +id estRows task access object operator info +TopN 0.83 root planner__core__casetest__physicalplantest__physical_plan.tn.d, offset:0, count:1 +└─IndexReader 0.83 root index:TopN + └─TopN 0.83 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.tn.d, offset:0, count:1 + └─Selection 0.83 cop[tikv] gt(planner__core__casetest__physicalplantest__physical_plan.tn.c, 50) + └─IndexRangeScan 2.50 cop[tikv] table:tn, index:a(a, b, c, d) range:(1 10,1 20), keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from tn where a = 1 and b > 10 and b < 20 and c > 50 order by d limit 1; +id estRows task access object operator info +TopN 0.83 root planner__core__casetest__physicalplantest__physical_plan.tn.d, offset:0, count:1 +└─IndexReader 0.83 root index:TopN + └─TopN 0.83 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.tn.d, offset:0, count:1 + └─Selection 0.83 cop[tikv] gt(planner__core__casetest__physicalplantest__physical_plan.tn.c, 50) + └─IndexRangeScan 2.50 cop[tikv] table:tn, index:a(a, b, c, d) range:(1 10,1 20), keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select /*+ LIMIT_TO_COP() */ a from tn where a div 2 order by a limit 1; +id estRows task access object operator info +Limit 1.00 root offset:0, count:1 +└─Selection 1.00 root intdiv(planner__core__casetest__physicalplantest__physical_plan.tn.a, 2) + └─IndexReader 1.00 root index:IndexFullScan + └─IndexFullScan 1.00 cop[tikv] table:tn, index:a(a, b, c, d) keep order:true, stats:pseudo +show warnings; +Level Code Message +Warning 1105 Scalar function 'intdiv'(signature: IntDivideInt, return type: bigint(20)) is not supported to push down to storage layer now. +Warning 1815 Optimizer Hint LIMIT_TO_COP is inapplicable +explain format = 'brief' select /*+ LIMIT_TO_COP() */ a from tn where a > 10 limit 1; +id estRows task access object operator info +Limit 1.00 root offset:0, count:1 +└─IndexReader 1.00 root index:Limit + └─Limit 1.00 cop[tikv] offset:0, count:1 + └─IndexRangeScan 1.00 cop[tikv] table:tn, index:a(a, b, c, d) range:(10,+inf], keep order:false, stats:pseudo +show warnings; +Level Code Message +set tidb_cost_model_version=DEFAULT; +set tidb_opt_limit_push_down_threshold=DEFAULT; +drop table if exists tc, te, t1, t2, t3, t4; +drop view if exists v; +create table tc(a int); +create table te(c int); +create table t1(a int); +create table t2(b int); +create table t3(c int); +create table t4(d int); +insert into tc values (1), (5), (10), (15), (20), (30), (50); +insert into te values (1), (5), (10), (25), (40), (60), (100); +insert into t1 values (1), (5), (10), (25), (40), (60), (100); +insert into t2 values (1), (5), (10), (25), (40), (60), (100); +insert into t3 values (1), (5), (10), (25), (40), (60), (100); +insert into t4 values (1), (5), (10), (25), (40), (60), (100); +analyze table tc; +analyze table te; +analyze table t1; +analyze table t2; +analyze table t3; +analyze table t4; +create definer='root'@'localhost' view v as select * from tc; +explain format = 'brief' with cte as (select /*+ MERGE() */ * from tc where tc.a < 60) select * from cte where cte.a <18; +id estRows task access object operator info +TableReader 4.00 root data:Selection +└─Selection 4.00 cop[tikv] lt(planner__core__casetest__physicalplantest__physical_plan.tc.a, 18), lt(planner__core__casetest__physicalplantest__physical_plan.tc.a, 60) + └─TableFullScan 7.00 cop[tikv] table:tc keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte as (select * from tc where tc.a < 60) select * from cte c1, cte c2 where c1.a <18; +id estRows task access object operator info +Projection 39.20 root planner__core__casetest__physicalplantest__physical_plan.tc.a, planner__core__casetest__physicalplantest__physical_plan.tc.a +└─HashJoin 39.20 root CARTESIAN inner join + ├─Selection(Build) 5.60 root lt(planner__core__casetest__physicalplantest__physical_plan.tc.a, 18) + │ └─CTEFullScan 7.00 root CTE:cte AS c1 data:CTE_0 + └─CTEFullScan(Probe) 7.00 root CTE:cte AS c2 data:CTE_0 +CTE_0 7.00 root Non-Recursive CTE +└─TableReader(Seed Part) 7.00 root data:Selection + └─Selection 7.00 cop[tikv] lt(planner__core__casetest__physicalplantest__physical_plan.tc.a, 60), or(lt(planner__core__casetest__physicalplantest__physical_plan.tc.a, 18), 1) + └─TableFullScan 7.00 cop[tikv] table:tc keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte as (select /*+ MERGE() */ * from v) select * from cte; +id estRows task access object operator info +TableReader 7.00 root data:TableFullScan +└─TableFullScan 7.00 cop[tikv] table:tc keep order:false +show warnings; +Level Code Message +explain format = 'brief' WITH cte1 AS (SELECT /*+ MERGE() */ a FROM tc), cte2 AS (SELECT /*+ MERGE()*/ c FROM te) SELECT * FROM cte1 JOIN cte2 WHERE cte1.a = cte2.c; +id estRows task access object operator info +HashJoin 7.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.tc.a, planner__core__casetest__physicalplantest__physical_plan.te.c)] +├─TableReader(Build) 7.00 root data:Selection +│ └─Selection 7.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.te.c)) +│ └─TableFullScan 7.00 cop[tikv] table:te keep order:false +└─TableReader(Probe) 7.00 root data:Selection + └─Selection 7.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tc.a)) + └─TableFullScan 7.00 cop[tikv] table:tc keep order:false +show warnings; +Level Code Message +explain format = 'brief' WITH cte1 AS (SELECT a FROM tc), cte2 AS (SELECT /*+ MERGE() */ c FROM te) SELECT * FROM cte1 JOIN cte2 WHERE cte1.a = cte2.c; +id estRows task access object operator info +HashJoin 7.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.tc.a, planner__core__casetest__physicalplantest__physical_plan.te.c)] +├─TableReader(Build) 7.00 root data:Selection +│ └─Selection 7.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.te.c)) +│ └─TableFullScan 7.00 cop[tikv] table:te keep order:false +└─TableReader(Probe) 7.00 root data:Selection + └─Selection 7.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tc.a)) + └─TableFullScan 7.00 cop[tikv] table:tc keep order:false +show warnings; +Level Code Message +explain format = 'brief' with recursive cte1(c1) as (select 1 union select /*+ MERGE() */ c1 + 1 c1 from cte1 where c1 < 100) select * from cte1; +id estRows task access object operator info +CTEFullScan 2.00 root CTE:cte1 data:CTE_0 +CTE_0 2.00 root Recursive CTE +├─Projection(Seed Part) 1.00 root 1->Column#2 +│ └─TableDual 1.00 root rows:1 +└─Projection(Recursive Part) 0.80 root cast(plus(Column#3, 1), bigint(1) BINARY)->Column#5 + └─Selection 0.80 root lt(Column#3, 100) + └─CTETable 1.00 root Scan on CTE_0 +show warnings; +Level Code Message +Warning 1815 Recursive CTE cte1 can not be inlined by merge() or tidb_opt_force_inline_cte. +explain format = 'brief' WITH cte1 AS (SELECT * FROM t1) SELECT /*+ MERGE() */ * FROM cte1 join t2 on cte1.a = t2.b; +id estRows task access object operator info +HashJoin 7.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 7.00 root data:Selection +│ └─Selection 7.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ └─TableFullScan 7.00 cop[tikv] table:t2 keep order:false +└─TableReader(Probe) 7.00 root data:Selection + └─Selection 7.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.a)) + └─TableFullScan 7.00 cop[tikv] table:t1 keep order:false +show warnings; +Level Code Message +Warning 1815 Hint merge() is inapplicable. Please check whether the hint is used in the right place, you should use this hint inside the CTE. +explain format = 'brief' with cte1 as (with cte3 as (select /*+ MERGE() */ * from t1),cte4 as (select /*+ MERGE() */ * from t2) select /*+ MERGE() */ * from cte3,cte4) ,cte2 as (select /*+ MERGE() */ * from t3) select * from cte1,cte2; +id estRows task access object operator info +HashJoin 343.00 root CARTESIAN inner join +├─TableReader(Build) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:t3 keep order:false +└─HashJoin(Probe) 49.00 root CARTESIAN inner join + ├─TableReader(Build) 7.00 root data:TableFullScan + │ └─TableFullScan 7.00 cop[tikv] table:t2 keep order:false + └─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:t1 keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte1 as (select * from tc), cte2 as (with cte3 as (select /*+ MERGE() */ * from te) ,cte4 as (select * from tc) select * from cte3,cte4) select * from cte2; +id estRows task access object operator info +HashJoin 49.00 root CARTESIAN inner join +├─TableReader(Build) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:tc keep order:false +└─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:te keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte1 as (with cte2 as (select /*+ MERGE() */ * from te) ,cte3 as (select /*+ MERGE() */ * from tc) select /*+ MERGE() */ * from cte2,cte3) select * from cte1; +id estRows task access object operator info +HashJoin 49.00 root CARTESIAN inner join +├─TableReader(Build) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:tc keep order:false +└─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:te keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte1 as (select * from t1), cte2 as (with cte3 as (with cte5 as (select * from t2),cte6 as (select * from t3) select * from cte5,cte6) ,cte4 as (select * from t4) select * from cte3,cte4) select * from cte1,cte2; +id estRows task access object operator info +HashJoin 2401.00 root CARTESIAN inner join +├─HashJoin(Build) 49.00 root CARTESIAN inner join +│ ├─TableReader(Build) 7.00 root data:TableFullScan +│ │ └─TableFullScan 7.00 cop[tikv] table:t4 keep order:false +│ └─TableReader(Probe) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:t3 keep order:false +└─HashJoin(Probe) 49.00 root CARTESIAN inner join + ├─TableReader(Build) 7.00 root data:TableFullScan + │ └─TableFullScan 7.00 cop[tikv] table:t2 keep order:false + └─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:t1 keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte1 as (select /*+ MERGE() */ * from t1), cte2 as (with cte3 as (with cte5 as (select * from t2),cte6 as (select * from t3) select * from cte5,cte6) ,cte4 as (select * from t4) select * from cte3,cte4) select * from cte1,cte2; +id estRows task access object operator info +HashJoin 2401.00 root CARTESIAN inner join +├─HashJoin(Build) 49.00 root CARTESIAN inner join +│ ├─TableReader(Build) 7.00 root data:TableFullScan +│ │ └─TableFullScan 7.00 cop[tikv] table:t4 keep order:false +│ └─TableReader(Probe) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:t3 keep order:false +└─HashJoin(Probe) 49.00 root CARTESIAN inner join + ├─TableReader(Build) 7.00 root data:TableFullScan + │ └─TableFullScan 7.00 cop[tikv] table:t2 keep order:false + └─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:t1 keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte1 as (select * from t1), cte2 as (with cte3 as (with cte5 as (select * from t2),cte6 as (select * from t3) select * from cte5,cte6) ,cte4 as (select /*+ MERGE() */ * from t4) select * from cte3,cte4) select * from cte1,cte2; +id estRows task access object operator info +HashJoin 2401.00 root CARTESIAN inner join +├─HashJoin(Build) 49.00 root CARTESIAN inner join +│ ├─TableReader(Build) 7.00 root data:TableFullScan +│ │ └─TableFullScan 7.00 cop[tikv] table:t4 keep order:false +│ └─TableReader(Probe) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:t3 keep order:false +└─HashJoin(Probe) 49.00 root CARTESIAN inner join + ├─TableReader(Build) 7.00 root data:TableFullScan + │ └─TableFullScan 7.00 cop[tikv] table:t2 keep order:false + └─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:t1 keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte1 as (select * from t1), cte2 as (with cte3 as (with cte5 as (select * from t2),cte6 as (select /*+ MERGE() */ * from t3) select * from cte5,cte6) ,cte4 as (select * from t4) select * from cte3,cte4) select * from cte1,cte2; +id estRows task access object operator info +HashJoin 2401.00 root CARTESIAN inner join +├─HashJoin(Build) 49.00 root CARTESIAN inner join +│ ├─TableReader(Build) 7.00 root data:TableFullScan +│ │ └─TableFullScan 7.00 cop[tikv] table:t4 keep order:false +│ └─TableReader(Probe) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:t3 keep order:false +└─HashJoin(Probe) 49.00 root CARTESIAN inner join + ├─TableReader(Build) 7.00 root data:TableFullScan + │ └─TableFullScan 7.00 cop[tikv] table:t2 keep order:false + └─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:t1 keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte2 as (with cte4 as (select * from tc) select * from te, cte4) select * from cte2; +id estRows task access object operator info +HashJoin 49.00 root CARTESIAN inner join +├─TableReader(Build) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:tc keep order:false +└─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:te keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte2 as (with cte4 as (select /*+ merge() */ * from tc) select * from te, cte4) select * from cte2; +id estRows task access object operator info +HashJoin 49.00 root CARTESIAN inner join +├─TableReader(Build) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:tc keep order:false +└─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:te keep order:false +show warnings; +Level Code Message +explain format = 'brief' with cte1 as (with cte2 as (with cte3 as (select /*+ MERGE() */ * from t2) select /*+ MERGE() */ * from cte3) select * from cte2,(select /*+ MERGE() */ * from t1) ttt) select * from cte1; +id estRows task access object operator info +HashJoin 49.00 root CARTESIAN inner join +├─TableReader(Build) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:t1 keep order:false +└─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:t2 keep order:false +show warnings; +Level Code Message +Warning 1815 Hint merge() is inapplicable. Please check whether the hint is used in the right place, you should use this hint inside the CTE. +Warning 1815 Hint merge() is inapplicable. Please check whether the hint is used in the right place, you should use this hint inside the CTE. +explain format = 'brief' with cte1 as (with cte2 as (with cte3 as (select /*+ MERGE() */ * from t2) select /*+ MERGE() */ * from cte3) select * from cte2,(select * from t1) ttt) select * from cte1,(select /*+ MERGE() */ * from t3) ttw; +id estRows task access object operator info +HashJoin 343.00 root CARTESIAN inner join +├─TableReader(Build) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:t3 keep order:false +└─HashJoin(Probe) 49.00 root CARTESIAN inner join + ├─TableReader(Build) 7.00 root data:TableFullScan + │ └─TableFullScan 7.00 cop[tikv] table:t1 keep order:false + └─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:t2 keep order:false +show warnings; +Level Code Message +Warning 1815 Hint merge() is inapplicable. Please check whether the hint is used in the right place, you should use this hint inside the CTE. +explain format = 'brief' with cte1 as (with cte2 as (with cte3 as (select /*+ MERGE() */ * from t2) select /*+ MERGE() */ * from cte3) select * from cte2,(select * from t1) ttt) select * from cte1,(select * from t3) ttw; +id estRows task access object operator info +HashJoin 343.00 root CARTESIAN inner join +├─TableReader(Build) 7.00 root data:TableFullScan +│ └─TableFullScan 7.00 cop[tikv] table:t3 keep order:false +└─HashJoin(Probe) 49.00 root CARTESIAN inner join + ├─TableReader(Build) 7.00 root data:TableFullScan + │ └─TableFullScan 7.00 cop[tikv] table:t1 keep order:false + └─TableReader(Probe) 7.00 root data:TableFullScan + └─TableFullScan 7.00 cop[tikv] table:t2 keep order:false +show warnings; +Level Code Message +set tidb_cost_model_version=2; +drop table if exists t; +CREATE TABLE `t` (`a` int(11)); +insert into t values (1), (5), (10), (15), (20), (30), (50); +set tidb_opt_force_inline_cte=1; -- enable force inline CTE; +explain format='brief' with cte as (select * from t) select * from cte; -- inline; +id estRows task access object operator info +TableReader 10000.00 root data:TableFullScan +└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format='brief' with cte as (select /*+ MERGE() */ * from t) select * from cte; -- inline; +id estRows task access object operator info +TableReader 10000.00 root data:TableFullScan +└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format='brief' with cte as (select * from t) select * from cte cte1, cte cte2; -- inline CTEs is used by multi consumers; +id estRows task access object operator info +HashJoin 100000000.00 root CARTESIAN inner join +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format='brief' with cte1 as (select * from t), cte2 as (select a from cte1 group by a) select * from cte1, cte2; -- multi inline CTEs; +id estRows task access object operator info +HashJoin 80000000.00 root CARTESIAN inner join +├─HashAgg(Build) 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.t.a, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t.a)->planner__core__casetest__physicalplantest__physical_plan.t.a +│ └─TableReader 8000.00 root data:HashAgg +│ └─HashAgg 8000.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.t.a, +│ └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format='brief' with recursive cte1(c1) as (select 1 union select c1 + 1 c1 from cte1 where c1 < 100) select * from cte1; -- Recursive CTE can not be inlined; +id estRows task access object operator info +CTEFullScan 2.00 root CTE:cte1 data:CTE_0 +CTE_0 2.00 root Recursive CTE +├─Projection(Seed Part) 1.00 root 1->Column#2 +│ └─TableDual 1.00 root rows:1 +└─Projection(Recursive Part) 0.80 root cast(plus(Column#3, 1), bigint(1) BINARY)->Column#5 + └─Selection 0.80 root lt(Column#3, 100) + └─CTETable 1.00 root Scan on CTE_0 +show warnings; +Level Code Message +Warning 1815 Recursive CTE cte1 can not be inlined by merge() or tidb_opt_force_inline_cte. +explain format='brief' with cte1 as (with cte2 as (select * from t) select * from cte2) select * from cte1; -- non-recursive 'cte2' definition inside another non-recursive 'cte1'; +id estRows task access object operator info +TableReader 10000.00 root data:TableFullScan +└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format='brief' with recursive cte2(c1) as (with cte1 as (select * from t) select a c1 from cte1 union select c1+1 c1 from cte2 where c1 < 100) select * from cte2; -- non-recursive 'cte1' inside recursive 'cte2'; +id estRows task access object operator info +CTEFullScan 8001.00 root CTE:cte2 data:CTE_0 +CTE_0 8001.00 root Recursive CTE +├─TableReader(Seed Part) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +└─Projection(Recursive Part) 8000.00 root cast(plus(planner__core__casetest__physicalplantest__physical_plan.t.a, 1), int(11))->planner__core__casetest__physicalplantest__physical_plan.t.a + └─Selection 8000.00 root lt(planner__core__casetest__physicalplantest__physical_plan.t.a, 100) + └─CTETable 10000.00 root Scan on CTE_0 +show warnings; +Level Code Message +Warning 1815 Recursive CTE cte2 can not be inlined by merge() or tidb_opt_force_inline_cte. +explain format='brief' with cte1 as (with recursive cte2(c1) as (select 1 union select c1 + 1 c1 from cte2 where c1 < 100) select * from cte2) select * from cte1; -- recursive 'cte2' inside non-recursive 'cte1'; +id estRows task access object operator info +CTEFullScan 2.00 root CTE:cte2 data:CTE_2 +CTE_2 2.00 root Recursive CTE +├─Projection(Seed Part) 1.00 root 1->Column#9 +│ └─TableDual 1.00 root rows:1 +└─Projection(Recursive Part) 0.80 root cast(plus(Column#10, 1), bigint(1) BINARY)->Column#12 + └─Selection 0.80 root lt(Column#10, 100) + └─CTETable 1.00 root Scan on CTE_2 +show warnings; +Level Code Message +Warning 1815 Recursive CTE cte2 can not be inlined by merge() or tidb_opt_force_inline_cte. +Warning 1815 Recursive CTE cte2 can not be inlined by merge() or tidb_opt_force_inline_cte. +set tidb_opt_force_inline_cte=0; -- disable force inline CTE; +explain format='brief' with cte as (select * from t) select * from cte; -- inlined by single consumer; +id estRows task access object operator info +TableReader 10000.00 root data:TableFullScan +└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format='brief' with cte as (select /*+ MERGE() */ * from t) select * from cte; -- inline, merge hint override session variable; +id estRows task access object operator info +TableReader 10000.00 root data:TableFullScan +└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format='brief' with recursive cte1(c1) as (select 1 union select /*+ MERGE() */ c1 + 1 c1 from cte1 where c1 < 100) select * from cte1; -- Recursive CTE can not be inlined; +id estRows task access object operator info +CTEFullScan 2.00 root CTE:cte1 data:CTE_0 +CTE_0 2.00 root Recursive CTE +├─Projection(Seed Part) 1.00 root 1->Column#2 +│ └─TableDual 1.00 root rows:1 +└─Projection(Recursive Part) 0.80 root cast(plus(Column#3, 1), bigint(1) BINARY)->Column#5 + └─Selection 0.80 root lt(Column#3, 100) + └─CTETable 1.00 root Scan on CTE_0 +show warnings; +Level Code Message +Warning 1815 Recursive CTE cte1 can not be inlined by merge() or tidb_opt_force_inline_cte. +explain format='brief' with cte1 as (with cte2 as (select * from t) select * from cte2) select * from cte1; -- non-recursive 'cte2' definition inside another non-recursive 'cte1'; +id estRows task access object operator info +TableReader 10000.00 root data:TableFullScan +└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format='brief' with recursive cte2(c1) as (with cte1 as (select * from t) select a c1 from cte1 union select c1+1 c1 from cte2 where c1 < 100) select * from cte2; -- non-recursive 'cte1' inside recursive 'cte2'; +id estRows task access object operator info +CTEFullScan 8001.00 root CTE:cte2 data:CTE_0 +CTE_0 8001.00 root Recursive CTE +├─TableReader(Seed Part) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +└─Projection(Recursive Part) 8000.00 root cast(plus(planner__core__casetest__physicalplantest__physical_plan.t.a, 1), int(11))->planner__core__casetest__physicalplantest__physical_plan.t.a + └─Selection 8000.00 root lt(planner__core__casetest__physicalplantest__physical_plan.t.a, 100) + └─CTETable 10000.00 root Scan on CTE_0 +show warnings; +Level Code Message +explain format='brief' with cte1 as (with recursive cte2(c1) as (select 1 union select c1 + 1 c1 from cte2 where c1 < 100) select * from cte2) select * from cte1; -- recursive 'cte2' inside non-recursive 'cte1'; +id estRows task access object operator info +CTEFullScan 2.00 root CTE:cte2 data:CTE_2 +CTE_2 2.00 root Recursive CTE +├─Projection(Seed Part) 1.00 root 1->Column#9 +│ └─TableDual 1.00 root rows:1 +└─Projection(Recursive Part) 0.80 root cast(plus(Column#10, 1), bigint(1) BINARY)->Column#12 + └─Selection 0.80 root lt(Column#10, 100) + └─CTETable 1.00 root Scan on CTE_2 +show warnings; +Level Code Message +set tidb_cost_model_version=DEFAULT; +set tidb_opt_force_inline_cte=DEFAULT; +drop table if exists t, t1, t2; +CREATE TABLE `t` (`a` int(11)); +create table t1 (c1 int primary key, c2 int, index c2 (c2)); +create table t2 (c1 int unique, c2 int); +insert into t values (1), (5), (10), (15), (20), (30), (50); +explain format='brief' with recursive cte1(c1) as (select c1 from t1 union select c1 from t2 limit 1) select * from cte1; -- non-recursive limit, inline cte1; +id estRows task access object operator info +Limit 1.00 root offset:0, count:1 +└─HashAgg 1.00 root group by:Column#18, funcs:firstrow(Column#18)->Column#18 + └─Union 20000.00 root + ├─TableReader 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─IndexReader 10000.00 root index:IndexFullScan + └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo +explain format='brief' with recursive cte1(c1) as (select c1 from t1 union select c1 from t2 limit 100 offset 100) select * from cte1; -- non-recursive limit, inline cte1; +id estRows task access object operator info +Limit 100.00 root offset:100, count:100 +└─HashAgg 200.00 root group by:Column#18, funcs:firstrow(Column#18)->Column#18 + └─Union 20000.00 root + ├─TableReader 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─IndexReader 10000.00 root index:IndexFullScan + └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo +explain format='brief' with recursive cte1(c1) as (select c1 from t1 union select c1 from t2 limit 0 offset 0) select * from cte1; -- non-recursive limit, inline cte1; +id estRows task access object operator info +TableDual 0.00 root rows:0 +explain format='brief' with cte1 as (select 1), cte2 as (select 2) select * from cte1 union (with cte2 as (select 3) select * from cte2 union all select * from cte2) -- inline cte1, not inline cte2; +id estRows task access object operator info +HashAgg 3.00 root group by:Column#9, funcs:firstrow(Column#9)->Column#9 +└─Union 3.00 root + ├─Projection 1.00 root 1->Column#9 + │ └─TableDual 1.00 root rows:1 + └─Union 2.00 root + ├─CTEFullScan 1.00 root CTE:cte2 data:CTE_2 + └─CTEFullScan 1.00 root CTE:cte2 data:CTE_2 +CTE_2 1.00 root Non-Recursive CTE +└─Projection(Seed Part) 1.00 root 3->Column#5 + └─TableDual 1.00 root rows:1 +explain format='brief' with base1 as (WITH RECURSIVE cte(a) AS (with tmp as (select 1 as a) SELECT a from tmp UNION SELECT a+1 FROM cte) SELECT * FROM cte) select * from base1; -- issue #43318; +id estRows task access object operator info +CTEFullScan 2.00 root CTE:cte data:CTE_3 +CTE_3 2.00 root Recursive CTE +├─Projection(Seed Part) 1.00 root 1->Column#15 +│ └─TableDual 1.00 root rows:1 +└─Projection(Recursive Part) 1.00 root cast(plus(Column#16, 1), bigint(1) BINARY)->Column#18 + └─CTETable 1.00 root Scan on CTE_3 +explain format='brief' with cte as (select 1) select * from cte; -- inline cte; +id estRows task access object operator info +Projection 1.00 root 1->Column#3 +└─TableDual 1.00 root rows:1 +explain format='brief' with cte1 as (select 1), cte2 as (select 2) select * from cte1 union select * from cte2; -- inline cte1, cte2; +id estRows task access object operator info +HashAgg 2.00 root group by:Column#7, funcs:firstrow(Column#7)->Column#7 +└─Union 2.00 root + ├─Projection 1.00 root 1->Column#7 + │ └─TableDual 1.00 root rows:1 + └─Projection 1.00 root 2->Column#7 + └─TableDual 1.00 root rows:1 +explain format='brief' with cte as (select 1) select * from cte union select * from cte; -- cannot be inlined; +id estRows task access object operator info +HashAgg 2.00 root group by:Column#4, funcs:firstrow(Column#4)->Column#4 +└─Union 2.00 root + ├─CTEFullScan 1.00 root CTE:cte data:CTE_0 + └─CTEFullScan 1.00 root CTE:cte data:CTE_0 +CTE_0 1.00 root Non-Recursive CTE +└─Projection(Seed Part) 1.00 root 1->Column#1 + └─TableDual 1.00 root rows:1 +explain format='brief' with cte as (with cte as (select 1) select * from cte) select * from cte; -- inline nested cte; +id estRows task access object operator info +Projection 1.00 root 1->Column#7 +└─TableDual 1.00 root rows:1 +explain format='brief' with cte as (with cte as (select 1) select * from cte) select * from cte a, cte b; -- inline inner cte, cannot be inlined outer cte; +id estRows task access object operator info +HashJoin 1.00 root CARTESIAN inner join +├─CTEFullScan(Build) 1.00 root CTE:cte AS b data:CTE_0 +└─CTEFullScan(Probe) 1.00 root CTE:cte AS a data:CTE_0 +CTE_0 1.00 root Non-Recursive CTE +└─Projection(Seed Part) 1.00 root 1->Column#3 + └─TableDual 1.00 root rows:1 +explain format='brief' with cte1 as (select 1), cte2 as (with cte3 as (select * from cte1) select * from cte3) select * from cte1, cte2; -- inline cte2, cte3, cannot be inlined cte1; +id estRows task access object operator info +HashJoin 1.00 root CARTESIAN inner join +├─CTEFullScan(Build) 1.00 root CTE:cte1 data:CTE_0 +└─CTEFullScan(Probe) 1.00 root CTE:cte1 data:CTE_0 +CTE_0 1.00 root Non-Recursive CTE +└─Projection(Seed Part) 1.00 root 1->Column#1 + └─TableDual 1.00 root rows:1 +explain format='brief' with cte1 as (select 1), cte2 as (with cte3 as (select * from cte1) select * from cte3) select * from cte2; -- inline cte1, cte2, cte3; +id estRows task access object operator info +Projection 1.00 root 1->Column#12 +└─TableDual 1.00 root rows:1 +explain format='brief' with cte1 as (select 1), cte2 as (select * from cte1) select * from cte2 a, cte2 b; -- inline cte1, cannot be inlined cte2; +id estRows task access object operator info +HashJoin 1.00 root CARTESIAN inner join +├─CTEFullScan(Build) 1.00 root CTE:cte2 AS b data:CTE_1 +└─CTEFullScan(Probe) 1.00 root CTE:cte2 AS a data:CTE_1 +CTE_1 1.00 root Non-Recursive CTE +└─Projection(Seed Part) 1.00 root 1->Column#3 + └─TableDual 1.00 root rows:1 +explain format='brief' with recursive cte(a) as (select 1 union select a from cte) select * from cte; -- recursive cte cannot be inlined; +id estRows task access object operator info +CTEFullScan 2.00 root CTE:cte data:CTE_0 +CTE_0 2.00 root Recursive CTE +├─Projection(Seed Part) 1.00 root 1->Column#2 +│ └─TableDual 1.00 root rows:1 +└─CTETable(Recursive Part) 1.00 root Scan on CTE_0 +explain format='brief' with x as (select * from (select a from t for update) s) select * from x where a = 1; +id estRows task access object operator info +Projection 10.00 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─SelectLock 10.00 root for update 0 + └─TableReader 10.00 root data:Selection + └─Selection 10.00 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t.a, 1) + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +set tidb_opt_force_inline_cte=1; -- enable force inline CTE; +explain format='brief' with cte as (select 1) select * from cte union select * from cte; -- force inline cte while multi-consumer; +id estRows task access object operator info +HashAgg 2.00 root group by:Column#6, funcs:firstrow(Column#6)->Column#6 +└─Union 2.00 root + ├─Projection 1.00 root 1->Column#6 + │ └─TableDual 1.00 root rows:1 + └─Projection 1.00 root 1->Column#6 + └─TableDual 1.00 root rows:1 +set tidb_opt_force_inline_cte=0; -- disable force inline CTE; +explain format='brief' with cte as (select 1) select /*+ MERGE() */ * from cte union select * from cte; -- firstly inline cte, secondly cannot be inlined; +id estRows task access object operator info +HashAgg 2.00 root group by:Column#4, funcs:firstrow(Column#4)->Column#4 +└─Union 2.00 root + ├─CTEFullScan 1.00 root CTE:cte data:CTE_0 + └─CTEFullScan 1.00 root CTE:cte data:CTE_0 +CTE_0 1.00 root Non-Recursive CTE +└─Projection(Seed Part) 1.00 root 1->Column#1 + └─TableDual 1.00 root rows:1 +explain format='brief' with a as (select 8 as id from dual),maxa as (select max(id) as max_id from a),b as (with recursive temp as (select 1 as lvl from dual union all select lvl+1 from temp, maxa where lvl < max_id)select * from temp) select * from b; -- issue #47711, maxa cannot be inlined because it contains agg and in the recursive part of cte temp; +id estRows task access object operator info +CTEFullScan 1.64 root CTE:temp data:CTE_4 +CTE_4 1.64 root Recursive CTE +├─Projection(Seed Part) 1.00 root 1->Column#14 +│ └─TableDual 1.00 root rows:1 +└─Projection(Recursive Part) 0.64 root cast(plus(Column#15, 1), bigint(1) BINARY)->Column#18 + └─HashJoin 0.64 root CARTESIAN inner join, other cond:lt(Column#15, Column#16) + ├─Selection(Build) 0.80 root not(isnull(Column#16)) + │ └─CTEFullScan 1.00 root CTE:maxa data:CTE_1 + └─Selection(Probe) 0.80 root not(isnull(Column#15)) + └─CTETable 1.00 root Scan on CTE_4 +CTE_1 1.00 root Non-Recursive CTE +└─StreamAgg(Seed Part) 1.00 root funcs:max(Column#3)->Column#4 + └─Projection 1.00 root 8->Column#3 + └─TableDual 1.00 root rows:1 +explain format='brief' with a as (select count(*) from t1), b as (select 2 as bb from a), c as (with recursive tmp as (select 1 as res from t1 union all select res+1 from tmp,b where res+1 < bb) select * from tmp) select * from c; -- inline a, cannot be inline b because b indirectly contains agg and in the recursive part of cte tmp; +id estRows task access object operator info +CTEFullScan 20000.00 root CTE:tmp data:CTE_4 +CTE_4 20000.00 root Recursive CTE +├─Projection(Seed Part) 10000.00 root 1->Column#26 +│ └─TableReader 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─Projection(Recursive Part) 10000.00 root cast(plus(Column#27, 1), bigint(1) BINARY)->Column#30 + └─HashJoin 10000.00 root CARTESIAN inner join, other cond:lt(plus(Column#27, 1), Column#28) + ├─CTEFullScan(Build) 1.00 root CTE:b data:CTE_1 + └─CTETable(Probe) 10000.00 root Scan on CTE_4 +CTE_1 1.00 root Non-Recursive CTE +└─Projection(Seed Part) 1.00 root 2->Column#8 + └─HashAgg 1.00 root funcs:count(Column#37)->Column#35 + └─TableReader 1.00 root data:HashAgg + └─HashAgg 1.00 cop[tikv] funcs:count(1)->Column#37 + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format='brief' with a as (select count(*) from t1), b as (select 2 as bb from a), c as (with recursive tmp as (select bb as res from b union all select res+1 from tmp where res +1 < 10) select * from tmp) select * from c; -- inline a, b, cannot be inline tmp, c; +id estRows task access object operator info +CTEFullScan 1.80 root CTE:tmp data:CTE_4 +CTE_4 1.80 root Recursive CTE +├─Projection(Seed Part) 1.00 root 2->Column#37 +│ └─HashAgg 1.00 root funcs:count(Column#46)->Column#44 +│ └─TableReader 1.00 root data:HashAgg +│ └─HashAgg 1.00 cop[tikv] funcs:count(1)->Column#46 +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─Projection(Recursive Part) 0.80 root cast(plus(Column#38, 1), bigint(1) BINARY)->Column#40 + └─Selection 0.80 root lt(plus(Column#38, 1), 10) + └─CTETable 1.00 root Scan on CTE_4 +drop table if exists t; +create table t(a int, b int, c int, index(c)); +insert into t values (1, 1, 1), (1, 1, 3), (1, 2, 3), (2, 1, 3), (1, 2, NULL); +drop table if exists pt; +CREATE TABLE pt (a int, b int) PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (2), +PARTITION p1 VALUES LESS THAN (100) +); +drop table if exists tc; +CREATE TABLE `tc`(`timestamp` timestamp NULL DEFAULT NULL, KEY `idx_timestamp` (`timestamp`)) PARTITION BY RANGE ( UNIX_TIMESTAMP(`timestamp`) ) (PARTITION `p2020072312` VALUES LESS THAN (1595480400),PARTITION `p2020072313` VALUES LESS THAN (1595484000)); +drop table if exists ta; +create table ta(a int); +insert into ta values(1), (1); +drop table if exists tb; +create table tb(a int); +insert into tb values(1), (1); +set session sql_mode=''; +set session tidb_hashagg_partial_concurrency=1; +set session tidb_hashagg_final_concurrency=1; +set @@tidb_partition_prune_mode='static'; +set @@session.tidb_opt_distinct_agg_push_down = 1; +set session tidb_opt_agg_push_down = 0; +set tidb_cost_model_version=2; +explain format = 'brief' select /*+ HASH_AGG(), AGG_TO_COP() */ sum(distinct b) from pt; +id estRows task access object operator info +HashAgg 1.00 root funcs:sum(distinct Column#9)->Column#4 +└─Projection 16000.00 root cast(planner__core__casetest__physicalplantest__physical_plan.pt.b, decimal(10,0) BINARY)->Column#9 + └─PartitionUnion 16000.00 root + ├─HashAgg 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.pt.b, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.pt.b)->planner__core__casetest__physicalplantest__physical_plan.pt.b, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.pt.b)->planner__core__casetest__physicalplantest__physical_plan.pt.b + │ └─TableReader 8000.00 root data:HashAgg + │ └─HashAgg 8000.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.pt.b, + │ └─TableFullScan 10000.00 cop[tikv] table:pt, partition:p0 keep order:false, stats:pseudo + └─HashAgg 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.pt.b, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.pt.b)->planner__core__casetest__physicalplantest__physical_plan.pt.b, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.pt.b)->planner__core__casetest__physicalplantest__physical_plan.pt.b + └─TableReader 8000.00 root data:HashAgg + └─HashAgg 8000.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.pt.b, + └─TableFullScan 10000.00 cop[tikv] table:pt, partition:p1 keep order:false, stats:pseudo +select /*+ HASH_AGG(), AGG_TO_COP() */ sum(distinct b) from pt; +sum(distinct b) +NULL +explain format = 'brief' select /*+ HASH_AGG(), AGG_TO_COP() */ count(distinct a) from (select * from ta union all select * from tb) t; +id estRows task access object operator info +HashAgg 1.00 root funcs:count(distinct Column#5)->Column#6 +└─Union 20000.00 root + ├─TableReader 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo + └─TableReader 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo +select /*+ HASH_AGG(), AGG_TO_COP() */ count(distinct a) from (select * from ta union all select * from tb) t; +count(distinct a) +1 +explain format = 'brief' select distinct DATE_FORMAT(timestamp, '%Y-%m-%d %H') as tt from tc ; +id estRows task access object operator info +HashAgg 16000.00 root group by:Column#5, funcs:firstrow(Column#6)->Column#3 +└─PartitionUnion 16000.00 root + ├─HashAgg 8000.00 root group by:Column#7, funcs:firstrow(Column#7)->Column#6, funcs:firstrow(Column#7)->Column#5 + │ └─IndexReader 8000.00 root index:HashAgg + │ └─HashAgg 8000.00 cop[tikv] group by:date_format(planner__core__casetest__physicalplantest__physical_plan.tc.timestamp, "%Y-%m-%d %H"), + │ └─IndexFullScan 10000.00 cop[tikv] table:tc, partition:p2020072312, index:idx_timestamp(timestamp) keep order:false, stats:pseudo + └─HashAgg 8000.00 root group by:Column#10, funcs:firstrow(Column#10)->Column#6, funcs:firstrow(Column#10)->Column#5 + └─IndexReader 8000.00 root index:HashAgg + └─HashAgg 8000.00 cop[tikv] group by:date_format(planner__core__casetest__physicalplantest__physical_plan.tc.timestamp, "%Y-%m-%d %H"), + └─IndexFullScan 10000.00 cop[tikv] table:tc, partition:p2020072313, index:idx_timestamp(timestamp) keep order:false, stats:pseudo +select distinct DATE_FORMAT(timestamp, '%Y-%m-%d %H') as tt from tc ; +tt +set session sql_mode=DEFAULT; +set session tidb_hashagg_partial_concurrency=DEFAULT; +set session tidb_hashagg_final_concurrency=DEFAULT; +set @@tidb_partition_prune_mode=DEFAULT; +set @@session.tidb_opt_distinct_agg_push_down = DEFAULT; +set session tidb_opt_agg_push_down = DEFAULT; +drop table if exists t; +create table t (a int, b int, index idx_a(a), index idx_b(b)); +insert into t values(1, 1); +insert into t values(1, 2); +insert into t values(2, 4); +insert into t values(3, 5); +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by t1.a; +id estRows task access object operator info +MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b +├─IndexReader(Build) 9990.00 root index:IndexFullScan +│ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo +└─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by t1.a; +a +1 +1 +2 +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by t1.a+1; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, plus(planner__core__casetest__physicalplantest__physical_plan.t.a, 1)->Column#7 + └─MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b + ├─IndexReader(Build) 9990.00 root index:IndexFullScan + │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo + └─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by t1.a+1; +a +1 +1 +2 +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by t1.a-1; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, minus(planner__core__casetest__physicalplantest__physical_plan.t.a, 1)->Column#7 + └─MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b + ├─IndexReader(Build) 9990.00 root index:IndexFullScan + │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo + └─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by t1.a-1; +a +1 +1 +2 +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by -t1.a; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, unaryminus(planner__core__casetest__physicalplantest__physical_plan.t.a)->Column#7 + └─MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b + ├─IndexReader(Build) 9990.00 root index:IndexFullScan + │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, desc, stats:pseudo + └─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, desc, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by -t1.a; +a +2 +1 +1 +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by -t1.a+3; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, plus(unaryminus(planner__core__casetest__physicalplantest__physical_plan.t.a), 3)->Column#7 + └─MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b + ├─IndexReader(Build) 9990.00 root index:IndexFullScan + │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, desc, stats:pseudo + └─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, desc, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by -t1.a+3; +a +2 +1 +1 +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1+t1.a; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, plus(1, planner__core__casetest__physicalplantest__physical_plan.t.a)->Column#7 + └─MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b + ├─IndexReader(Build) 9990.00 root index:IndexFullScan + │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo + └─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1+t1.a; +a +1 +1 +2 +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1-t1.a; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, minus(1, planner__core__casetest__physicalplantest__physical_plan.t.a)->Column#7 + └─MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b + ├─IndexReader(Build) 9990.00 root index:IndexFullScan + │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, desc, stats:pseudo + └─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, desc, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1-t1.a; +a +2 +1 +1 +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1-t1.a+3; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, plus(minus(1, planner__core__casetest__physicalplantest__physical_plan.t.a), 3)->Column#7 + └─MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b + ├─IndexReader(Build) 9990.00 root index:IndexFullScan + │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, desc, stats:pseudo + └─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, desc, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1-t1.a+3; +a +2 +1 +1 +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1+t1.a+3; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, plus(plus(1, planner__core__casetest__physicalplantest__physical_plan.t.a), 3)->Column#7 + └─MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b + ├─IndexReader(Build) 9990.00 root index:IndexFullScan + │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo + └─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 1+t1.a+3; +a +1 +1 +2 +explain format = 'brief' select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 3*t1.a; +id estRows task access object operator info +Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a +└─Sort 12487.50 root Column#7 + └─Projection 12487.50 root planner__core__casetest__physicalplantest__physical_plan.t.a, mul(3, planner__core__casetest__physicalplantest__physical_plan.t.a)->Column#7 + └─MergeJoin 12487.50 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t.a, right key:planner__core__casetest__physicalplantest__physical_plan.t.b + ├─IndexReader(Build) 9990.00 root index:IndexFullScan + │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx_b(b) keep order:true, stats:pseudo + └─IndexReader(Probe) 9990.00 root index:IndexFullScan + └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_a(a) keep order:true, stats:pseudo +select /*+ TIDB_SMJ(t1, t2) */ t1.a from t t1, t t2 where t1.a = t2.b order by 3*t1.a; +a +1 +1 +2 +drop table if exists test.tt; +create table test.tt (a int,b int, index(a), index(b)); +insert into test.tt values (1, 1), (2, 2), (3, 4); +set @@tidb_partition_prune_mode='static'; +explain format = 'brief' select /*+nth_plan(1)*/ * from test.tt where a=1 and b=1; +id estRows task access object operator info +TableReader 0.01 root data:Selection +└─Selection 0.01 cop[tikv] eq(test.tt.a, 1), eq(test.tt.b, 1) + └─TableFullScan 10000.00 cop[tikv] table:tt keep order:false, stats:pseudo +explain format = 'brief' select /*+nth_plan(2)*/ * from test.tt where a=1 and b=1; +id estRows task access object operator info +IndexLookUp 0.01 root +├─IndexRangeScan(Build) 10.00 cop[tikv] table:tt, index:a(a) range:[1,1], keep order:false, stats:pseudo +└─Selection(Probe) 0.01 cop[tikv] eq(test.tt.b, 1) + └─TableRowIDScan 10.00 cop[tikv] table:tt keep order:false, stats:pseudo +explain format = 'brief' select /*+nth_plan(3)*/ * from test.tt where a=1 and b=1; +id estRows task access object operator info +IndexLookUp 0.01 root +├─IndexRangeScan(Build) 10.00 cop[tikv] table:tt, index:b(b) range:[1,1], keep order:false, stats:pseudo +└─Selection(Probe) 0.01 cop[tikv] eq(test.tt.a, 1) + └─TableRowIDScan 10.00 cop[tikv] table:tt keep order:false, stats:pseudo +explain format = 'brief' select /*+nth_plan(2)*/ * from test.tt where a=1 and b=1; +id estRows task access object operator info +IndexLookUp 0.01 root +├─IndexRangeScan(Build) 10.00 cop[tikv] table:tt, index:a(a) range:[1,1], keep order:false, stats:pseudo +└─Selection(Probe) 0.01 cop[tikv] eq(test.tt.b, 1) + └─TableRowIDScan 10.00 cop[tikv] table:tt keep order:false, stats:pseudo +explain format = 'brief' select * from test.tt where a=1 and b=1; +id estRows task access object operator info +IndexLookUp 0.01 root +├─IndexRangeScan(Build) 10.00 cop[tikv] table:tt, index:a(a) range:[1,1], keep order:false, stats:pseudo +└─Selection(Probe) 0.01 cop[tikv] eq(test.tt.b, 1) + └─TableRowIDScan 10.00 cop[tikv] table:tt keep order:false, stats:pseudo +set @@tidb_partition_prune_mode=DEFAULT; +drop table if exists t; +create table t(e enum('c','b','a',''), index idx(e)); +insert ignore into t values(0),(1),(2),(3),(4); +explain format='brief' select e from t where e = 'b'; +id estRows task access object operator info +IndexReader 10.00 root index:IndexRangeScan +└─IndexRangeScan 10.00 cop[tikv] table:t, index:idx(e) range:["b","b"], keep order:false, stats:pseudo +select e from t where e = 'b'; +e +b +explain format='brief' select e from t where e != 'b'; +id estRows task access object operator info +IndexReader 40.00 root index:IndexRangeScan +└─IndexRangeScan 40.00 cop[tikv] table:t, index:idx(e) range:["",""], ["c","c"], ["a","a"], ["",""], keep order:false, stats:pseudo +select e from t where e != 'b'; +e + + +a +c +explain format='brief' select e from t where e > 'b'; +id estRows task access object operator info +IndexReader 10.00 root index:IndexRangeScan +└─IndexRangeScan 10.00 cop[tikv] table:t, index:idx(e) range:["c","c"], keep order:false, stats:pseudo +select e from t where e > 'b'; +e +c +explain format='brief' select e from t where e >= 'b'; +id estRows task access object operator info +IndexReader 20.00 root index:IndexRangeScan +└─IndexRangeScan 20.00 cop[tikv] table:t, index:idx(e) range:["c","c"], ["b","b"], keep order:false, stats:pseudo +select e from t where e >= 'b'; +e +b +c +explain format='brief' select e from t where e < 'b'; +id estRows task access object operator info +IndexReader 30.00 root index:IndexRangeScan +└─IndexRangeScan 30.00 cop[tikv] table:t, index:idx(e) range:["",""], ["a","a"], ["",""], keep order:false, stats:pseudo +select e from t where e < 'b'; +e + + +a +explain format='brief' select e from t where e <= 'b'; +id estRows task access object operator info +IndexReader 40.00 root index:IndexRangeScan +└─IndexRangeScan 40.00 cop[tikv] table:t, index:idx(e) range:["",""], ["b","b"], ["a","a"], ["",""], keep order:false, stats:pseudo +select e from t where e <= 'b'; +e + + +a +b +explain format='brief' select e from t where e = 2; +id estRows task access object operator info +IndexReader 10.00 root index:IndexRangeScan +└─IndexRangeScan 10.00 cop[tikv] table:t, index:idx(e) range:["b","b"], keep order:false, stats:pseudo +select e from t where e = 2; +e +b +explain format='brief' select e from t where e != 2; +id estRows task access object operator info +IndexReader 6656.67 root index:IndexRangeScan +└─IndexRangeScan 6656.67 cop[tikv] table:t, index:idx(e) range:[-inf,"b"), ("b",+inf], keep order:false, stats:pseudo +select e from t where e != 2; +e + + +a +c +explain format='brief' select e from t where e > 2; +id estRows task access object operator info +IndexReader 3333.33 root index:IndexRangeScan +└─IndexRangeScan 3333.33 cop[tikv] table:t, index:idx(e) range:("b",+inf], keep order:false, stats:pseudo +select e from t where e > 2; +e + +a +explain format='brief' select e from t where e >= 2; +id estRows task access object operator info +IndexReader 3333.33 root index:IndexRangeScan +└─IndexRangeScan 3333.33 cop[tikv] table:t, index:idx(e) range:["b",+inf], keep order:false, stats:pseudo +select e from t where e >= 2; +e + +a +b +explain format='brief' select e from t where e < 2; +id estRows task access object operator info +IndexReader 3323.33 root index:IndexRangeScan +└─IndexRangeScan 3323.33 cop[tikv] table:t, index:idx(e) range:[-inf,"b"), keep order:false, stats:pseudo +select e from t where e < 2; +e + +c +explain format='brief' select e from t where e <= 2; +id estRows task access object operator info +IndexReader 3323.33 root index:IndexRangeScan +└─IndexRangeScan 3323.33 cop[tikv] table:t, index:idx(e) range:[-inf,"b"], keep order:false, stats:pseudo +select e from t where e <= 2; +e + +b +c +explain format='brief' select e from t where e > ''; +id estRows task access object operator info +IndexReader 30.00 root index:IndexRangeScan +└─IndexRangeScan 30.00 cop[tikv] table:t, index:idx(e) range:["c","c"], ["b","b"], ["a","a"], keep order:false, stats:pseudo +select e from t where e > ''; +e +a +b +c +explain format='brief' select e from t where e > 'd'; +id estRows task access object operator info +TableDual 0.00 root rows:0 +select e from t where e > 'd'; +e +explain format='brief' select e from t where e > -1; +id estRows task access object operator info +IndexReader 3333.33 root index:IndexRangeScan +└─IndexRangeScan 3333.33 cop[tikv] table:t, index:idx(e) range:["",+inf], keep order:false, stats:pseudo +select e from t where e > -1; +e + + +a +b +c +explain format='brief' select e from t where e > 5; +id estRows task access object operator info +IndexReader 3333.33 root index:IndexRangeScan +└─IndexRangeScan 3333.33 cop[tikv] table:t, index:idx(e) range:("",+inf], keep order:false, stats:pseudo +select e from t where e > 5; +e +explain format='brief' select e from t where e = ''; +id estRows task access object operator info +IndexReader 20.00 root index:IndexRangeScan +└─IndexRangeScan 20.00 cop[tikv] table:t, index:idx(e) range:["",""], ["",""], keep order:false, stats:pseudo +select e from t where e = ''; +e + + +explain format='brief' select e from t where e != ''; +id estRows task access object operator info +IndexReader 30.00 root index:IndexRangeScan +└─IndexRangeScan 30.00 cop[tikv] table:t, index:idx(e) range:["c","c"], ["b","b"], ["a","a"], keep order:false, stats:pseudo +select e from t where e != ''; +e +a +b +c +drop table if exists PK_S_MULTI_31; +CREATE TABLE `PK_S_MULTI_31` ( +`COL1` tinyint(45) NOT NULL, +`COL2` tinyint(45) NOT NULL, +PRIMARY KEY (`COL1`,`COL2`) /*T![clustered_index] NONCLUSTERED */ +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +insert into PK_S_MULTI_31 values(122,100),(124,-22),(124,34),(127,103); +explain format='brief' SELECT col2 FROM PK_S_MULTI_31 AS T1 WHERE (SELECT count(DISTINCT COL1, COL2) FROM PK_S_MULTI_31 AS T2 WHERE T2.COL1>T1.COL1)>2 order by col2; +id estRows task access object operator info +Sort 0.80 root planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col2 +└─Projection 0.80 root planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col2 + └─Selection 0.80 root gt(Column#7, 2) + └─HashAgg 1.00 root group by:planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col1, planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col2, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col2)->planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col2, funcs:count(distinct planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col1, planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col2)->Column#7 + └─HashJoin 100000000.00 root CARTESIAN left outer join, other cond:gt(planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col1, planner__core__casetest__physicalplantest__physical_plan.pk_s_multi_31.col1) + ├─IndexReader(Build) 10000.00 root index:IndexFullScan + │ └─IndexFullScan 10000.00 cop[tikv] table:T2, index:PRIMARY(COL1, COL2) keep order:false, stats:pseudo + └─IndexReader(Probe) 10000.00 root index:IndexFullScan + └─IndexFullScan 10000.00 cop[tikv] table:T1, index:PRIMARY(COL1, COL2) keep order:false, stats:pseudo +SELECT col2 FROM PK_S_MULTI_31 AS T1 WHERE (SELECT count(DISTINCT COL1, COL2) FROM PK_S_MULTI_31 AS T2 WHERE T2.COL1>T1.COL1)>2 order by col2; +col2 +100 +drop table if exists t1, t2; +create table t1(a int, b int as (a+1) virtual); +create table t2(a int, b int as (a+1) virtual, c int, key idx_a(a)); +## Make sure row_count(tikv_selection) == row_count(table_reader) and row_count(table_reader) > row_count(tidb_selection) +explain format='brief' select * from t1 where a > 1 and b > 1; +id estRows task access object operator info +Selection 1111.11 root gt(planner__core__casetest__physicalplantest__physical_plan.t1.b, 1) +└─TableReader 3333.33 root data:Selection + └─Selection 3333.33 cop[tikv] gt(planner__core__casetest__physicalplantest__physical_plan.t1.a, 1) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +## Make sure row_count(tikv_selection) == row_count(index_lookup) and row_count(index_lookup) > row_count(tidb_selection) +explain format='brief' select * from t2 use index(idx_a) where a > 1 and b > 1 and c > 1; +id estRows task access object operator info +Selection 370.37 root gt(planner__core__casetest__physicalplantest__physical_plan.t2.b, 1) +└─IndexLookUp 1111.11 root + ├─IndexRangeScan(Build) 3333.33 cop[tikv] table:t2, index:idx_a(a) range:(1,+inf], keep order:false, stats:pseudo + └─Selection(Probe) 1111.11 cop[tikv] gt(planner__core__casetest__physicalplantest__physical_plan.t2.c, 1) + └─TableRowIDScan 3333.33 cop[tikv] table:t2 keep order:false, stats:pseudo +drop table if exists t; +create table t(a int); +explain format='brief' select * from t where t.a < 3 and t.a < 3; +id estRows task access object operator info +TableReader 3323.33 root data:Selection +└─Selection 3323.33 cop[tikv] lt(planner__core__casetest__physicalplantest__physical_plan.t.a, 3) + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +set tidb_cost_model_version=2; +drop table if exists t; +CREATE TABLE `t` (`a` int(11), `b` int(11), `c` int(11), `d` date); +insert into t (a,b,c,d) value(1,4,5,'2019-06-01'); +insert into t (a,b,c,d) value(2,null,1,'2019-07-01'); +insert into t (a,b,c,d) value(3,4,5,'2019-08-01'); +insert into t (a,b,c,d) value(3,6,2,'2019-09-01'); +insert into t (a,b,c,d) value(10,4,null,'2020-06-01'); +insert into t (a,b,c,d) value(20,null,1,'2020-07-01'); +insert into t (a,b,c,d) value(30,4,5,'2020-08-01'); +insert into t (a,b,c,d) value(30,6,5,'2020-09-01'); +select date_format(d,'%Y') as df, sum(a), count(b), count(distinct c) from t group by date_format(d,'%Y') order by df; +df sum(a) count(b) count(distinct c) +2019 9 3 3 +2020 90 3 2 +set @@tidb_opt_skew_distinct_agg=1; +select date_format(d,'%Y') as df, sum(a), count(b), count(distinct c) from t group by date_format(d,'%Y') order by df; +df sum(a) count(b) count(distinct c) +2019 9 3 3 +2020 90 3 2 +select count(distinct b), sum(c) from t group by a order by 1,2; +count(distinct b) sum(c) +0 1 +0 1 +1 NULL +1 5 +2 7 +2 10 +select count(distinct b) from t group by date_format(d,'%Y') order by 1; +count(distinct b) +2 +2 +select count(a), count(distinct b), max(b) from t group by date_format(d,'%Y') order by 1,2,3; +count(a) count(distinct b) max(b) +4 2 6 +4 2 6 +select count(a), count(distinct b), max(b) from t group by date_format(d,'%Y'),c order by 1,2,3; +count(a) count(distinct b) max(b) +1 0 NULL +1 0 NULL +1 1 4 +1 1 6 +2 1 4 +2 2 6 +select avg(distinct b), count(a), sum(b) from t group by date_format(d,'%Y'),c order by 1,2,3; +avg(distinct b) count(a) sum(b) +NULL 1 NULL +NULL 1 NULL +4.0000 1 4 +4.0000 2 8 +5.0000 2 10 +6.0000 1 6 +explain format='brief' select date_format(d,'%Y') as df, sum(a), count(b), count(distinct c) from t group by date_format(d,'%Y'); +id estRows task access object operator info +Projection 8000.00 root date_format(planner__core__casetest__physicalplantest__physical_plan.t.d, %Y)->Column#9, Column#6, cast(Column#13, bigint(21) BINARY)->Column#7, Column#8 +└─HashAgg 8000.00 root group by:Column#23, funcs:sum(Column#19)->Column#6, funcs:sum(Column#20)->Column#13, funcs:count(Column#21)->Column#8, funcs:firstrow(Column#22)->planner__core__casetest__physicalplantest__physical_plan.t.d + └─Projection 8000.00 root Column#11->Column#19, cast(Column#12, decimal(20,0) BINARY)->Column#20, planner__core__casetest__physicalplantest__physical_plan.t.c->Column#21, planner__core__casetest__physicalplantest__physical_plan.t.d->Column#22, date_format(planner__core__casetest__physicalplantest__physical_plan.t.d, %Y)->Column#23 + └─HashAgg 8000.00 root group by:Column#14, planner__core__casetest__physicalplantest__physical_plan.t.c, funcs:sum(Column#15)->Column#11, funcs:count(Column#16)->Column#12, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t.c)->planner__core__casetest__physicalplantest__physical_plan.t.c, funcs:firstrow(Column#18)->planner__core__casetest__physicalplantest__physical_plan.t.d + └─TableReader 8000.00 root data:HashAgg + └─HashAgg 8000.00 cop[tikv] group by:date_format(planner__core__casetest__physicalplantest__physical_plan.t.d, "%Y"), planner__core__casetest__physicalplantest__physical_plan.t.c, funcs:sum(planner__core__casetest__physicalplantest__physical_plan.t.a)->Column#15, funcs:count(planner__core__casetest__physicalplantest__physical_plan.t.b)->Column#16, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t.d)->Column#18 + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +explain format='brief' select d, a, count(*), count(b), count(distinct c) from t group by d, a; +id estRows task access object operator info +Projection 8000.00 root planner__core__casetest__physicalplantest__physical_plan.t.d, planner__core__casetest__physicalplantest__physical_plan.t.a, cast(Column#10, bigint(21) BINARY)->Column#6, cast(Column#12, bigint(21) BINARY)->Column#7, Column#8 +└─HashAgg 8000.00 root group by:Column#23, Column#24, funcs:sum(Column#18)->Column#10, funcs:sum(Column#19)->Column#12, funcs:count(Column#20)->Column#8, funcs:firstrow(Column#21)->planner__core__casetest__physicalplantest__physical_plan.t.a, funcs:firstrow(Column#22)->planner__core__casetest__physicalplantest__physical_plan.t.d + └─Projection 8000.00 root cast(Column#9, decimal(20,0) BINARY)->Column#18, cast(Column#11, decimal(20,0) BINARY)->Column#19, planner__core__casetest__physicalplantest__physical_plan.t.c->Column#20, planner__core__casetest__physicalplantest__physical_plan.t.a->Column#21, planner__core__casetest__physicalplantest__physical_plan.t.d->Column#22, planner__core__casetest__physicalplantest__physical_plan.t.d->Column#23, planner__core__casetest__physicalplantest__physical_plan.t.a->Column#24 + └─HashAgg 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.c, planner__core__casetest__physicalplantest__physical_plan.t.d, funcs:count(Column#13)->Column#9, funcs:count(Column#14)->Column#11, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t.c)->planner__core__casetest__physicalplantest__physical_plan.t.c, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t.a)->planner__core__casetest__physicalplantest__physical_plan.t.a, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t.d)->planner__core__casetest__physicalplantest__physical_plan.t.d + └─TableReader 8000.00 root data:HashAgg + └─HashAgg 8000.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.c, planner__core__casetest__physicalplantest__physical_plan.t.d, funcs:count(1)->Column#13, funcs:count(planner__core__casetest__physicalplantest__physical_plan.t.b)->Column#14 + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +explain format='brief' select d, sum(a), count(b), avg(distinct c) from t group by d; +id estRows task access object operator info +Projection 8000.00 root planner__core__casetest__physicalplantest__physical_plan.t.d, Column#6, cast(Column#11, bigint(21) BINARY)->Column#7, Column#8 +└─HashAgg 8000.00 root group by:Column#20, funcs:sum(Column#16)->Column#6, funcs:sum(Column#17)->Column#11, funcs:avg(Column#18)->Column#8, funcs:firstrow(Column#19)->planner__core__casetest__physicalplantest__physical_plan.t.d + └─Projection 8000.00 root Column#9->Column#16, cast(Column#10, decimal(20,0) BINARY)->Column#17, cast(planner__core__casetest__physicalplantest__physical_plan.t.c, decimal(10,0) BINARY)->Column#18, planner__core__casetest__physicalplantest__physical_plan.t.d->Column#19, planner__core__casetest__physicalplantest__physical_plan.t.d->Column#20 + └─HashAgg 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.t.c, planner__core__casetest__physicalplantest__physical_plan.t.d, funcs:sum(Column#12)->Column#9, funcs:count(Column#13)->Column#10, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t.c)->planner__core__casetest__physicalplantest__physical_plan.t.c, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t.d)->planner__core__casetest__physicalplantest__physical_plan.t.d + └─TableReader 8000.00 root data:HashAgg + └─HashAgg 8000.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.t.c, planner__core__casetest__physicalplantest__physical_plan.t.d, funcs:sum(planner__core__casetest__physicalplantest__physical_plan.t.a)->Column#12, funcs:count(planner__core__casetest__physicalplantest__physical_plan.t.b)->Column#13 + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +set tidb_cost_model_version=DEFAULT; +set @@tidb_opt_skew_distinct_agg=DEFAULT; +set tidb_cost_model_version=2; +drop table if exists t1, t2, t3; +create table t1(a int primary key, b int not null); +create table t2(a int primary key, b int not null); +create table t3(a int primary key, b int not null); +insert into t1 values(1,1),(2,2); +insert into t2 values(1,1),(2,1); +insert into t3 values(1,1),(2,1); +explain format = 'brief' select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t2), hash_join_probe(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2), hash_join_probe(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t2), hash_join_build(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2), hash_join_build(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +2 NULL +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +2 NULL +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +2 NULL +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 left join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +2 NULL +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 right join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root right outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 right join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +NULL 2 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 right join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root right outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 right join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +NULL 2 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 right join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root right outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 right join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +NULL 2 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 right join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root right outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 right join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +NULL 2 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 straight_join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 straight_join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 straight_join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 straight_join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 straight_join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 straight_join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 straight_join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 straight_join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 cross join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 cross join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 cross join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 cross join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 cross join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 cross join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 cross join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 cross join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t1) */ * from t1 where t1.a in (select t2.a from t2 where t1.b = t2.b); +id estRows task access object operator info +HashJoin 8000.00 root semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) */ * from t1 where t1.a in (select t2.a from t2 where t1.b = t2.b); +a b +1 1 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' select /*+ hash_join_probe(t1) */ * from t1 where t1.a in (select t2.a from t2 where t1.b = t2.b); +id estRows task access object operator info +HashJoin 8000.00 root semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) */ * from t1 where t1.a in (select t2.a from t2 where t1.b = t2.b); +a b +1 1 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' select /*+ hash_join_build(t2@sel_2) */ * from t1 where t1.a in (select t2.a from t2 where t1.b = t2.b); +id estRows task access object operator info +HashJoin 8000.00 root semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2@sel_2) */ * from t1 where t1.a in (select t2.a from t2 where t1.b = t2.b); +a b +1 1 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' select /*+ hash_join_probe(t2@sel_2) */ * from t1 where t1.a in (select t2.a from t2 where t1.b = t2.b); +id estRows task access object operator info +HashJoin 8000.00 root semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2@sel_2) */ * from t1 where t1.a in (select t2.a from t2 where t1.b = t2.b); +a b +1 1 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' select /*+ hash_join_build(t1) */ * from t1 where t1.a not in (select t2.a from t2 where t1.b = t2.b); +id estRows task access object operator info +HashJoin 8000.00 root anti semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) */ * from t1 where t1.a not in (select t2.a from t2 where t1.b = t2.b); +a b +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti semi join, please check the hint +explain format = 'brief' select /*+ hash_join_probe(t1) */ * from t1 where t1.a not in (select t2.a from t2 where t1.b = t2.b); +id estRows task access object operator info +HashJoin 8000.00 root anti semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) */ * from t1 where t1.a not in (select t2.a from t2 where t1.b = t2.b); +a b +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti semi join, please check the hint +explain format = 'brief' select /*+ hash_join_build(t2@sel_2) */ * from t1 where t1.a not in (select t2.a from t2 where t1.b = t2.b); +id estRows task access object operator info +HashJoin 8000.00 root anti semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2@sel_2) */ * from t1 where t1.a not in (select t2.a from t2 where t1.b = t2.b); +a b +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti semi join, please check the hint +explain format = 'brief' select /*+ hash_join_probe(t2@sel_2) */ * from t1 where t1.a not in (select t2.a from t2 where t1.b = t2.b); +id estRows task access object operator info +HashJoin 8000.00 root anti semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b) eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2@sel_2) */ * from t1 where t1.a not in (select t2.a from t2 where t1.b = t2.b); +a b +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti semi join, please check the hint +explain format = 'brief' select /*+ hash_join_build(t1) */ sum(t1.a in (select a from t2)) from t1; +id estRows task access object operator info +HashAgg 1.00 root funcs:sum(Column#9)->Column#8 +└─Projection 10000.00 root cast(Column#7, decimal(3,0) BINARY)->Column#9 + └─MergeJoin 10000.00 root left outer semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +select /*+ hash_join_build(t1) */ sum(t1.a in (select a from t2)) from t1; +sum(t1.a in (select a from t2)) +2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for left outer semi join, please check the hint +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for left outer semi join, please check the hint +explain format = 'brief' select /*+ hash_join_probe(t1) */ sum(t1.a in (select a from t2)) from t1; +id estRows task access object operator info +HashAgg 1.00 root funcs:sum(Column#9)->Column#8 +└─Projection 10000.00 root cast(Column#7, decimal(3,0) BINARY)->Column#9 + └─MergeJoin 10000.00 root left outer semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +select /*+ hash_join_probe(t1) */ sum(t1.a in (select a from t2)) from t1; +sum(t1.a in (select a from t2)) +2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for left outer semi join, please check the hint +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for left outer semi join, please check the hint +explain format = 'brief' select /*+ hash_join_build(t2@sel_2) */ sum(t1.a in (select a from t2)) from t1; +id estRows task access object operator info +HashAgg 1.00 root funcs:sum(Column#9)->Column#8 +└─Projection 10000.00 root cast(Column#7, decimal(3,0) BINARY)->Column#9 + └─MergeJoin 10000.00 root left outer semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +select /*+ hash_join_build(t2@sel_2) */ sum(t1.a in (select a from t2)) from t1; +sum(t1.a in (select a from t2)) +2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for left outer semi join, please check the hint +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for left outer semi join, please check the hint +explain format = 'brief' select /*+ hash_join_probe(t2@sel_2) */ sum(t1.a in (select a from t2)) from t1; +id estRows task access object operator info +HashAgg 1.00 root funcs:sum(Column#9)->Column#8 +└─Projection 10000.00 root cast(Column#7, decimal(3,0) BINARY)->Column#9 + └─MergeJoin 10000.00 root left outer semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +select /*+ hash_join_probe(t2@sel_2) */ sum(t1.a in (select a from t2)) from t1; +sum(t1.a in (select a from t2)) +2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for left outer semi join, please check the hint +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for left outer semi join, please check the hint +explain format = 'brief' select /*+ hash_join_build(t1) */ sum(t1.a not in (select a from t2)) from t1; +id estRows task access object operator info +HashAgg 1.00 root funcs:sum(Column#9)->Column#8 +└─Projection 10000.00 root cast(Column#7, decimal(3,0) BINARY)->Column#9 + └─MergeJoin 10000.00 root anti left outer semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +select /*+ hash_join_build(t1) */ sum(t1.a not in (select a from t2)) from t1; +sum(t1.a not in (select a from t2)) +0 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti left outer semi join, please check the hint +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti left outer semi join, please check the hint +explain format = 'brief' select /*+ hash_join_probe(t1) */ sum(t1.a not in (select a from t2)) from t1; +id estRows task access object operator info +HashAgg 1.00 root funcs:sum(Column#9)->Column#8 +└─Projection 10000.00 root cast(Column#7, decimal(3,0) BINARY)->Column#9 + └─MergeJoin 10000.00 root anti left outer semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +select /*+ hash_join_probe(t1) */ sum(t1.a not in (select a from t2)) from t1; +sum(t1.a not in (select a from t2)) +0 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti left outer semi join, please check the hint +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti left outer semi join, please check the hint +explain format = 'brief' select /*+ hash_join_build(t2@sel_2) */ sum(t1.a not in (select a from t2)) from t1; +id estRows task access object operator info +HashAgg 1.00 root funcs:sum(Column#9)->Column#8 +└─Projection 10000.00 root cast(Column#7, decimal(3,0) BINARY)->Column#9 + └─MergeJoin 10000.00 root anti left outer semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +select /*+ hash_join_build(t2@sel_2) */ sum(t1.a not in (select a from t2)) from t1; +sum(t1.a not in (select a from t2)) +0 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti left outer semi join, please check the hint +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti left outer semi join, please check the hint +explain format = 'brief' select /*+ hash_join_probe(t2@sel_2) */ sum(t1.a not in (select a from t2)) from t1; +id estRows task access object operator info +HashAgg 1.00 root funcs:sum(Column#9)->Column#8 +└─Projection 10000.00 root cast(Column#7, decimal(3,0) BINARY)->Column#9 + └─MergeJoin 10000.00 root anti left outer semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +select /*+ hash_join_probe(t2@sel_2) */ sum(t1.a not in (select a from t2)) from t1; +sum(t1.a not in (select a from t2)) +0 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti left outer semi join, please check the hint +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for anti left outer semi join, please check the hint +explain format = 'brief' select /*+ hash_join_probe(t2, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 There are no matching table names for (t2) in optimizer hint /*+ HASH_JOIN_PROBE(t2, t2) */. Maybe you can use the table alias name +explain format = 'brief' select /*+ hash_join_build(t1, t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1, t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 There are no matching table names for (t1) in optimizer hint /*+ HASH_JOIN_BUILD(t1, t1) */. Maybe you can use the table alias name +explain format = 'brief' select /*+ hash_join_probe(tt) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(tt) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 There are no matching table names for (tt) in optimizer hint /*+ HASH_JOIN_PROBE(tt) */. Maybe you can use the table alias name +explain format = 'brief' select /*+ hash_join_build(tt) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(tt) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 There are no matching table names for (tt) in optimizer hint /*+ HASH_JOIN_BUILD(tt) */. Maybe you can use the table alias name +explain format = 'brief' select /*+ hash_join_probe(tt) */ tt.a, t2.a from t1 as tt join t2 on tt.a=t2.a and tt.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:tt keep order:false, stats:pseudo +select /*+ hash_join_probe(tt) */ tt.a, t2.a from t1 as tt join t2 on tt.a=t2.a and tt.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(tt) */ tt.a, t2.a from t1 as tt join t2 on tt.a=t2.a and tt.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:tt keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(tt) */ tt.a, t2.a from t1 as tt join t2 on tt.a=t2.a and tt.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t2, t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2, t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints conflict after join reorder phase, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints conflict after join reorder phase, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t1) hash_join_probe(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) hash_join_probe(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t2) hash_join_probe(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) hash_join_probe(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t1) leading(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +id estRows task access object operator info +HashJoin 15625.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t3.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─HashJoin(Probe) 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) leading(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t1) leading(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +id estRows task access object operator info +Projection 15625.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a +└─HashJoin 15625.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t3.a)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo + └─HashJoin(Probe) 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.a) eq(planner__core__casetest__physicalplantest__physical_plan.t2.b, planner__core__casetest__physicalplantest__physical_plan.t1.b)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) leading(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t1) leading(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +id estRows task access object operator info +HashJoin 15625.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t3.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─HashJoin(Probe) 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) leading(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t1) leading(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +id estRows task access object operator info +Projection 15625.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a +└─HashJoin 15625.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t3.a)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo + └─HashJoin(Probe) 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.a) eq(planner__core__casetest__physicalplantest__physical_plan.t2.b, planner__core__casetest__physicalplantest__physical_plan.t1.b)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) leading(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t1) straight_join() */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +id estRows task access object operator info +HashJoin 15625.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t3.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─HashJoin(Probe) 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) straight_join() */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t1) straight_join() */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +id estRows task access object operator info +HashJoin 15625.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t3.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─HashJoin(Probe) 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) straight_join() */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t1) straight_join() */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +id estRows task access object operator info +HashJoin 15625.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t3.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─HashJoin(Probe) 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) straight_join() */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_probe(t1) straight_join() */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +id estRows task access object operator info +HashJoin 15625.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t3.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─HashJoin(Probe) 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) straight_join() */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b join t3 on t2.a = t3.a; +a a +1 1 +show warnings; +Level Code Message +explain format = 'brief' select /*+ hash_join_build(t2) hash_join(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) hash_join(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_probe(t2) hash_join(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) hash_join(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t2) hash_join(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) hash_join(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints conflict after join reorder phase, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_probe(t2) hash_join(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) hash_join(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints conflict after join reorder phase, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t2) hash_join(t2, t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) hash_join(t2, t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_probe(t2) hash_join(t2, t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) hash_join(t2, t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t2) INL_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) INL_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints conflict after join reorder phase, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_probe(t2) INL_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) INL_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints conflict after join reorder phase, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t1) INL_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) INL_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_probe(t1) INL_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) INL_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t2) INL_HASH_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) INL_HASH_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints conflict after join reorder phase, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_probe(t2) INL_HASH_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) INL_HASH_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints conflict after join reorder phase, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t1) INL_HASH_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) INL_HASH_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_probe(t1) INL_HASH_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) INL_HASH_JOIN(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t2) merge_join(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) merge_join(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_probe(t2) merge_join(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) merge_join(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_build(t1) merge_join(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) merge_join(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' select /*+ hash_join_probe(t1) merge_join(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) merge_join(t1, t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +show warnings; +Level Code Message +Warning 1815 Join hints are conflict, you can only specify one type of join +explain format = 'brief' SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ hash_join_probe(t1) */ * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ hash_join_probe(t1) */ * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +a b +1 1 +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' SELECT /*+ hash_join_probe(t2@sel_2) */ * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ hash_join_probe(t2@sel_2) */ * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +a b +1 1 +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' SELECT /*+ hash_join_probe(t1) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a); +id estRows task access object operator info +HashJoin 10000.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─StreamAgg(Build) 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.t2.a, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t2.a)->planner__core__casetest__physicalplantest__physical_plan.t2.a +│ └─TableReader 8000.00 root data:StreamAgg +│ └─StreamAgg 8000.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.t2.a, +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +SELECT /*+ hash_join_probe(t1) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ hash_join_probe(t2@sel_2) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a); +id estRows task access object operator info +HashJoin 10000.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─StreamAgg(Probe) 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.t2.a, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t2.a)->planner__core__casetest__physicalplantest__physical_plan.t2.a + └─TableReader 8000.00 root data:StreamAgg + └─StreamAgg 8000.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.t2.a, + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +SELECT /*+ hash_join_probe(t2@sel_2) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ hash_join_build(t1) */ * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ hash_join_build(t1) */ * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +a b +1 1 +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' SELECT /*+ hash_join_build(t2@sel_2) */ * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ hash_join_build(t2@sel_2) */ * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a = t1.a); +a b +1 1 +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' SELECT /*+ hash_join_build(t1) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a); +id estRows task access object operator info +HashJoin 10000.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─StreamAgg(Probe) 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.t2.a, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t2.a)->planner__core__casetest__physicalplantest__physical_plan.t2.a + └─TableReader 8000.00 root data:StreamAgg + └─StreamAgg 8000.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.t2.a, + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +SELECT /*+ hash_join_build(t1) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ hash_join_build(t2@sel_2) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a); +id estRows task access object operator info +HashJoin 10000.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─StreamAgg(Build) 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.t2.a, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t2.a)->planner__core__casetest__physicalplantest__physical_plan.t2.a +│ └─TableReader 8000.00 root data:StreamAgg +│ └─StreamAgg 8000.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.t2.a, +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +SELECT /*+ hash_join_build(t2@sel_2) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +MergeJoin 12500.00 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ hash_join_build(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +SELECT /*+ hash_join_build(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ hash_join_probe(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +SELECT /*+ hash_join_probe(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ hash_join_build(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +SELECT /*+ hash_join_build(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ hash_join_probe(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +SELECT /*+ hash_join_probe(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ USE_TOJA(TRUE) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +MergeJoin 12500.00 root inner join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ USE_TOJA(TRUE) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ USE_TOJA(TRUE) hash_join_build(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +SELECT /*+ USE_TOJA(TRUE) hash_join_build(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ USE_TOJA(TRUE) hash_join_probe(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +SELECT /*+ USE_TOJA(TRUE) hash_join_probe(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ USE_TOJA(TRUE) hash_join_build(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +SELECT /*+ USE_TOJA(TRUE) hash_join_build(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ USE_TOJA(TRUE) hash_join_probe(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +SELECT /*+ USE_TOJA(TRUE) hash_join_probe(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ USE_TOJA(false) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ USE_TOJA(false) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +explain format = 'brief' SELECT /*+ USE_TOJA(false) hash_join_build(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ USE_TOJA(false) hash_join_build(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' SELECT /*+ USE_TOJA(false) hash_join_probe(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ USE_TOJA(false) hash_join_probe(t1) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' SELECT /*+ USE_TOJA(false) hash_join_build(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ USE_TOJA(false) hash_join_build(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +explain format = 'brief' SELECT /*+ USE_TOJA(false) hash_join_probe(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +id estRows task access object operator info +MergeJoin 8000.00 root semi join, left key:planner__core__casetest__physicalplantest__physical_plan.t1.a, right key:planner__core__casetest__physicalplantest__physical_plan.t2.a +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo +SELECT /*+ USE_TOJA(false) hash_join_probe(t2@sel_2) */ t1.a, t1.b FROM t1 WHERE t1.a in (SELECT t2.a FROM t2); +a b +1 1 +2 2 +show warnings; +Level Code Message +Warning 1815 We can't use the HASH_JOIN_BUILD or HASH_JOIN_PROBE hint for semi join, please check the hint +set tidb_cost_model_version=DEFAULT; +set tidb_cost_model_version=2; +drop table if exists t1, t2, t3; +create table t1(a int, b int) partition by hash(a) partitions 4; +create table t2(a int, b int) partition by hash(a) partitions 5; +create table t3(a int, b int) partition by hash(b) partitions 3; +insert into t1 values(1,1),(2,2); +insert into t2 values(1,1),(2,1); +insert into t3 values(1,1),(2,1); +set @@tidb_partition_prune_mode="static"; +explain format = 'brief' select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 49900.05 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─PartitionUnion(Build) 49900.05 root +│ ├─TableReader 9980.01 root data:Selection +│ │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +│ ├─TableReader 9980.01 root data:Selection +│ │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +│ ├─TableReader 9980.01 root data:Selection +│ │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +│ ├─TableReader 9980.01 root data:Selection +│ │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +│ └─TableReader 9980.01 root data:Selection +│ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo +└─PartitionUnion(Probe) 39920.04 root + ├─TableReader 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, partition:p0 keep order:false, stats:pseudo + ├─TableReader 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, partition:p1 keep order:false, stats:pseudo + ├─TableReader 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, partition:p2 keep order:false, stats:pseudo + └─TableReader 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, partition:p3 keep order:false, stats:pseudo +select /*+ hash_join_build(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +explain format = 'brief' select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 49900.05 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─PartitionUnion(Build) 39920.04 root +│ ├─TableReader 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, partition:p0 keep order:false, stats:pseudo +│ ├─TableReader 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, partition:p1 keep order:false, stats:pseudo +│ ├─TableReader 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, partition:p2 keep order:false, stats:pseudo +│ └─TableReader 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, partition:p3 keep order:false, stats:pseudo +└─PartitionUnion(Probe) 49900.05 root + ├─TableReader 9980.01 root data:Selection + │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo + ├─TableReader 9980.01 root data:Selection + │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo + ├─TableReader 9980.01 root data:Selection + │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo + ├─TableReader 9980.01 root data:Selection + │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo + └─TableReader 9980.01 root data:Selection + └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo +select /*+ hash_join_probe(t2) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +explain format = 'brief' select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 49900.05 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─PartitionUnion(Build) 39920.04 root +│ ├─TableReader 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, partition:p0 keep order:false, stats:pseudo +│ ├─TableReader 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, partition:p1 keep order:false, stats:pseudo +│ ├─TableReader 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, partition:p2 keep order:false, stats:pseudo +│ └─TableReader 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, partition:p3 keep order:false, stats:pseudo +└─PartitionUnion(Probe) 49900.05 root + ├─TableReader 9980.01 root data:Selection + │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo + ├─TableReader 9980.01 root data:Selection + │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo + ├─TableReader 9980.01 root data:Selection + │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo + ├─TableReader 9980.01 root data:Selection + │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo + └─TableReader 9980.01 root data:Selection + └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo +select /*+ hash_join_build(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +explain format = 'brief' select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +id estRows task access object operator info +HashJoin 49900.05 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.a) eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.b)] +├─PartitionUnion(Build) 49900.05 root +│ ├─TableReader 9980.01 root data:Selection +│ │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p0 keep order:false, stats:pseudo +│ ├─TableReader 9980.01 root data:Selection +│ │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p1 keep order:false, stats:pseudo +│ ├─TableReader 9980.01 root data:Selection +│ │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p2 keep order:false, stats:pseudo +│ ├─TableReader 9980.01 root data:Selection +│ │ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ │ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p3 keep order:false, stats:pseudo +│ └─TableReader 9980.01 root data:Selection +│ └─Selection 9980.01 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.a)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) +│ └─TableFullScan 10000.00 cop[tikv] table:t2, partition:p4 keep order:false, stats:pseudo +└─PartitionUnion(Probe) 39920.04 root + ├─TableReader 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, partition:p0 keep order:false, stats:pseudo + ├─TableReader 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, partition:p1 keep order:false, stats:pseudo + ├─TableReader 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, partition:p2 keep order:false, stats:pseudo + └─TableReader 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, partition:p3 keep order:false, stats:pseudo +select /*+ hash_join_probe(t1) */ t1.a, t2.a from t1 join t2 on t1.a=t2.a and t1.b=t2.b; +a a +1 1 +set tidb_cost_model_version=DEFAULT; +set @@tidb_partition_prune_mode=DEFAULT; +set tidb_cost_model_version=2; +drop table if exists t1, t2, t3, ta, tb, tc, td; +create table t1(a int, b int); +create table t2(a int primary key, b int); +create table t3(a int, b int); +insert into t1 values(1,1),(2,2); +insert into t2 values(1,1),(2,1); +insert into t3 values(1,1),(2,1); +create table ta(id int, code int, name varchar(20), index idx_ta_id(id),index idx_ta_name(name), index idx_ta_code(code)); +create table tb(id int, code int, name varchar(20), index idx_tb_id(id),index idx_tb_name(name)); +create table tc(id int, code int, name varchar(20), index idx_tc_id(id),index idx_tc_name(name)); +create table td(id int, code int, name varchar(20), index idx_tc_id(id),index idx_tc_name(name)); +explain format = 'brief' select /*+ no_decorrelate() */ * from t1; +id estRows task access object operator info +TableReader 10000.00 root data:TableFullScan +└─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select /*+ no_decorrelate() */ * from t1; +a b +1 1 +2 2 +show warnings; +Level Code Message +Warning 1815 NO_DECORRELATE() is inapplicable because it's not in an IN subquery, an EXISTS subquery, an ANY/ALL/SOME subquery or a scalar subquery. +explain format = 'brief' select * from t1, (select /*+ no_decorrelate() */ * from t2) n; +id estRows task access object operator info +HashJoin 100000000.00 root CARTESIAN inner join +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select * from t1, (select /*+ no_decorrelate() */ * from t2) n; +a b a b +1 1 1 1 +1 1 2 1 +2 2 1 1 +2 2 2 1 +show warnings; +Level Code Message +Warning 1815 NO_DECORRELATE() is inapplicable because it's not in an IN subquery, an EXISTS subquery, an ANY/ALL/SOME subquery or a scalar subquery. +explain format = 'brief' select a+1, b-1 from (select /*+ no_decorrelate() */ * from t1) n; +id estRows task access object operator info +Projection 10000.00 root plus(planner__core__casetest__physicalplantest__physical_plan.t1.a, 1)->Column#4, minus(planner__core__casetest__physicalplantest__physical_plan.t1.b, 1)->Column#5 +└─TableReader 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select a+1, b-1 from (select /*+ no_decorrelate() */ * from t1) n; +a+1 b-1 +2 0 +3 1 +show warnings; +Level Code Message +Warning 1815 NO_DECORRELATE() is inapplicable because it's not in an IN subquery, an EXISTS subquery, an ANY/ALL/SOME subquery or a scalar subquery. +explain format = 'brief' select exists (select /*+ semi_join_rewrite(), no_decorrelate() */ * from t1 where t1.a=t3.a) from t3; +id estRows task access object operator info +HashJoin 10000.00 root left outer semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t3.a, planner__core__casetest__physicalplantest__physical_plan.t1.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +select exists (select /*+ semi_join_rewrite(), no_decorrelate() */ * from t1 where t1.a=t3.a) from t3; +exists (select /*+ semi_join_rewrite(), no_decorrelate() * from t1 where t1.a=t3.a) +1 +1 +show warnings; +Level Code Message +Warning 1815 NO_DECORRELATE() and SEMI_JOIN_REWRITE() are in conflict. Both will be ineffective. +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, 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 +select t1.a from t1 where t1.a in (select t2.b from t2 where t2.a = t1.b); +a +1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a from t1 where t1.a in (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b); +id estRows task access object operator info +Projection 9990.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a +└─Apply 9990.00 root semi join, equal:[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.t1.a)) + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─TableReader(Probe) 99800.10 root data:Selection + └─Selection 99800.10 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b)) + └─TableRangeScan 9990.00 cop[tikv] table:t2 range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.b)], keep order:false, stats:pseudo +select t1.a from t1 where t1.a in (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b); +a +1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a from t1 where t1.a = any (select t2.b from t2 where t2.a = t1.b); +id estRows task access object operator info +Projection 8000.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a +└─Selection 8000.00 root Column#6 + └─HashJoin 10000.00 root left outer semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.a)], other cond:eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.b) + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select t1.a from t1 where t1.a = any (select t2.b from t2 where t2.a = t1.b); +a +1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a from t1 where t1.a = any (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b); +id estRows task access object operator info +Projection 8000.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a +└─Selection 8000.00 root Column#6 + └─Apply 10000.00 root CARTESIAN left outer semi join, other cond:eq(planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.b) + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableRangeScan + └─TableRangeScan 10000.00 cop[tikv] table:t2 range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.b)], keep order:false, stats:pseudo +select t1.a from t1 where t1.a = any (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b); +a +1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, t1.a != any (select t2.b from t2 where t2.a = t1.b) from t1; +id estRows task access object operator info +Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a, and(or(or(gt(Column#9, 1), ne(planner__core__casetest__physicalplantest__physical_plan.t1.a, Column#8)), if(ne(Column#10, 0), , 0)), and(ne(Column#11, 0), if(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.a), , 1)))->Column#12 +└─Apply 10000.00 root CARTESIAN inner join + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─StreamAgg(Probe) 10000.00 root funcs:max(Column#14)->Column#8, funcs:count(distinct Column#15)->Column#9, funcs:sum(Column#16)->Column#10, funcs:count(1)->Column#11 + └─Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t2.b->Column#14, planner__core__casetest__physicalplantest__physical_plan.t2.b->Column#15, cast(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b), decimal(20,0) BINARY)->Column#16 + └─TableReader 10000.00 root data:TableRangeScan + └─TableRangeScan 10000.00 cop[tikv] table:t2 range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.b)], keep order:false, stats:pseudo +select t1.a, t1.a != any (select t2.b from t2 where t2.a = t1.b) from t1; +a t1.a != any (select t2.b from t2 where t2.a = t1.b) +1 0 +2 1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, t1.a != any (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b) from t1; +id estRows task access object operator info +Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a, and(or(or(gt(Column#9, 1), ne(planner__core__casetest__physicalplantest__physical_plan.t1.a, Column#8)), if(ne(Column#10, 0), , 0)), and(ne(Column#11, 0), if(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.a), , 1)))->Column#12 +└─Apply 10000.00 root CARTESIAN inner join + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─StreamAgg(Probe) 10000.00 root funcs:max(Column#14)->Column#8, funcs:count(distinct Column#15)->Column#9, funcs:sum(Column#16)->Column#10, funcs:count(1)->Column#11 + └─Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t2.b->Column#14, planner__core__casetest__physicalplantest__physical_plan.t2.b->Column#15, cast(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b), decimal(20,0) BINARY)->Column#16 + └─TableReader 10000.00 root data:TableRangeScan + └─TableRangeScan 10000.00 cop[tikv] table:t2 range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.b)], keep order:false, stats:pseudo +select t1.a, t1.a != any (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b) from t1; +a t1.a != any (select /*+ no_decorrelate() t2.b from t2 where t2.a = t1.b) +1 0 +2 1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, t1.a > all (select t2.b from t2 where t2.a = t1.b) from t1; +id estRows task access object operator info +Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a, or(and(gt(planner__core__casetest__physicalplantest__physical_plan.t1.a, Column#8), if(ne(Column#9, 0), , 1)), or(eq(Column#10, 0), if(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.a), , 0)))->Column#11 +└─Apply 10000.00 root CARTESIAN inner join + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─StreamAgg(Probe) 10000.00 root funcs:max(Column#19)->Column#8, funcs:sum(Column#20)->Column#9, funcs:count(1)->Column#10 + └─Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t2.b->Column#19, cast(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b), decimal(20,0) BINARY)->Column#20 + └─TableReader 10000.00 root data:TableRangeScan + └─TableRangeScan 10000.00 cop[tikv] table:t2 range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.b)], keep order:false, stats:pseudo +select t1.a, t1.a > all (select t2.b from t2 where t2.a = t1.b) from t1; +a t1.a > all (select t2.b from t2 where t2.a = t1.b) +1 0 +2 1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, t1.a > all (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b) from t1; +id estRows task access object operator info +Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a, or(and(gt(planner__core__casetest__physicalplantest__physical_plan.t1.a, Column#8), if(ne(Column#9, 0), , 1)), or(eq(Column#10, 0), if(isnull(planner__core__casetest__physicalplantest__physical_plan.t1.a), , 0)))->Column#11 +└─Apply 10000.00 root CARTESIAN inner join + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─StreamAgg(Probe) 10000.00 root funcs:max(Column#19)->Column#8, funcs:sum(Column#20)->Column#9, funcs:count(1)->Column#10 + └─Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t2.b->Column#19, cast(isnull(planner__core__casetest__physicalplantest__physical_plan.t2.b), decimal(20,0) BINARY)->Column#20 + └─TableReader 10000.00 root data:TableRangeScan + └─TableRangeScan 10000.00 cop[tikv] table:t2 range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.b)], keep order:false, stats:pseudo +select t1.a, t1.a > all (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b) from t1; +a t1.a > all (select /*+ no_decorrelate() t2.b from t2 where t2.a = t1.b) +1 0 +2 1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, (select t2.b from t2 where t2.a = t1.b) from t1; +id estRows task access object operator info +HashJoin 12500.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t2.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select t1.a, (select t2.b from t2 where t2.a = t1.b) from t1; +a (select t2.b from t2 where t2.a = t1.b) +1 1 +2 1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b) from t1; +id estRows task access object operator info +Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a, planner__core__casetest__physicalplantest__physical_plan.t2.b +└─Apply 10000.00 root CARTESIAN left outer join + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─MaxOneRow(Probe) 10000.00 root + └─TableReader 2000.00 root data:TableRangeScan + └─TableRangeScan 2000.00 cop[tikv] table:t2 range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, planner__core__casetest__physicalplantest__physical_plan.t1.b)], keep order:false, stats:pseudo +select t1.a, (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b) from t1; +a (select /*+ no_decorrelate() t2.b from t2 where t2.a = t1.b) +1 1 +2 1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, t1.b not in (select t3.b from t3) from t1; +id estRows task access object operator info +HashJoin 10000.00 root Null-aware anti left outer semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t3.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select t1.a, t1.b not in (select t3.b from t3) from t1; +a t1.b not in (select t3.b from t3) +1 0 +2 1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, t1.b not in (select /*+ no_decorrelate() */ t3.b from t3) from t1; +id estRows task access object operator info +HashJoin 10000.00 root Null-aware anti left outer semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t3.b)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select t1.a, t1.b not in (select /*+ no_decorrelate() */ t3.b from t3) from t1; +a t1.b not in (select /*+ no_decorrelate() t3.b from t3) +1 0 +2 1 +show warnings; +Level Code Message +Warning 1815 NO_DECORRELATE() is inapplicable because there are no correlated columns. +explain format = 'brief' select exists (select t3.b from t3 where t3.a = t1.b limit 2) from t1; +id estRows task access object operator info +HashJoin 10000.00 root left outer semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t3.a)] +├─TableReader(Build) 10000.00 root data:TableFullScan +│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select exists (select t3.b from t3 where t3.a = t1.b limit 2) from t1; +exists (select t3.b from t3 where t3.a = t1.b limit 2) +1 +1 +show warnings; +Level Code Message +explain format = 'brief' select exists (select /*+ no_decorrelate() */ t3.b from t3 where t3.a = t1.b limit 2) from t1; +id estRows task access object operator info +Projection 10000.00 root Column#10 +└─Apply 10000.00 root CARTESIAN left outer semi join + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─Limit(Probe) 20000.00 root offset:0, count:2 + └─TableReader 20000.00 root data:Limit + └─Limit 20000.00 cop[tikv] offset:0, count:2 + └─Selection 20000.00 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t3.a, planner__core__casetest__physicalplantest__physical_plan.t1.b) + └─TableFullScan 20000000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +select exists (select /*+ no_decorrelate() */ t3.b from t3 where t3.a = t1.b limit 2) from t1; +exists (select /*+ no_decorrelate() t3.b from t3 where t3.a = t1.b limit 2) +1 +1 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, (select sum(t1.a) from t2 where t2.a = 10) from t1; +id estRows task access object operator info +Projection 1.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a, Column#6->Column#11 +└─HashJoin 1.00 root CARTESIAN left outer join + ├─Point_Get(Build) 1.00 root table:t2 handle:10 + └─HashAgg(Probe) 1.00 root funcs:sum(Column#13)->Column#6, funcs:firstrow(Column#14)->planner__core__casetest__physicalplantest__physical_plan.t1.a + └─TableReader 1.00 root data:HashAgg + └─HashAgg 1.00 cop[tikv] funcs:sum(planner__core__casetest__physicalplantest__physical_plan.t1.a)->Column#13, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t1.a)->Column#14 + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select t1.a, (select sum(t1.a) from t2 where t2.a = 10) from t1; +a (select sum(t1.a) from t2 where t2.a = 10) +1 3 +show warnings; +Level Code Message +explain format = 'brief' select t1.a, (select /*+ no_decorrelate() */ sum(t1.a) from t2 where t2.a = 10) from t1; +id estRows task access object operator info +Projection 1.00 root planner__core__casetest__physicalplantest__physical_plan.t1.a, Column#9->Column#11 +└─Apply 1.00 root CARTESIAN left outer join + ├─HashAgg(Build) 1.00 root funcs:sum(Column#14)->Column#6, funcs:firstrow(Column#15)->planner__core__casetest__physicalplantest__physical_plan.t1.a + │ └─Projection 10000.00 root cast(planner__core__casetest__physicalplantest__physical_plan.t1.a, decimal(10,0) BINARY)->Column#14, planner__core__casetest__physicalplantest__physical_plan.t1.a->Column#15 + │ └─TableReader 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─MaxOneRow(Probe) 1.00 root + └─Projection 1.00 root Column#6->Column#9 + └─Point_Get 1.00 root table:t2 handle:10 +select t1.a, (select /*+ no_decorrelate() */ sum(t1.a) from t2 where t2.a = 10) from t1; +a (select /*+ no_decorrelate() sum(t1.a) from t2 where t2.a = 10) +1 NULL +show warnings; +Level Code Message +explain format = 'brief' select (select count(t3.a) from t3 where t3.b = t1.b) from t1; +id estRows task access object operator info +Projection 10000.00 root ifnull(Column#10, 0)->Column#10 +└─HashJoin 10000.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t1.b, planner__core__casetest__physicalplantest__physical_plan.t3.b)] + ├─HashAgg(Build) 7992.00 root group by:planner__core__casetest__physicalplantest__physical_plan.t3.b, funcs:count(Column#11)->Column#10, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t3.b)->planner__core__casetest__physicalplantest__physical_plan.t3.b + │ └─TableReader 7992.00 root data:HashAgg + │ └─HashAgg 7992.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.t3.b, funcs:count(planner__core__casetest__physicalplantest__physical_plan.t3.a)->Column#11 + │ └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.t3.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +select (select count(t3.a) from t3 where t3.b = t1.b) from t1; +(select count(t3.a) from t3 where t3.b = t1.b) +0 +2 +show warnings; +Level Code Message +explain format = 'brief' select (select /*+ no_decorrelate() */ count(t3.a) from t3 where t3.b = t1.b) from t1; +id estRows task access object operator info +Projection 10000.00 root Column#10 +└─Apply 10000.00 root CARTESIAN left outer join + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─MaxOneRow(Probe) 10000.00 root + └─StreamAgg 10000.00 root funcs:count(Column#12)->Column#10 + └─TableReader 10000.00 root data:StreamAgg + └─StreamAgg 10000.00 cop[tikv] funcs:count(planner__core__casetest__physicalplantest__physical_plan.t3.a)->Column#12 + └─Selection 100000.00 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t3.b, planner__core__casetest__physicalplantest__physical_plan.t1.b) + └─TableFullScan 100000000.00 cop[tikv] table:t3 keep order:false, stats:pseudo +select (select /*+ no_decorrelate() */ count(t3.a) from t3 where t3.b = t1.b) from t1; +(select /*+ no_decorrelate() count(t3.a) from t3 where t3.b = t1.b) +0 +2 +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.NAME,(SELECT sum(tb.CODE) FROM tb WHERE ta.id = tb.id) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +id estRows task access object operator info +HashJoin 250.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.tb.id)] +├─TableReader(Build) 250.00 root data:Selection +│ └─Selection 250.00 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.ta.name, "chad999%", 92) +│ └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo +└─HashAgg(Probe) 7992.00 root group by:planner__core__casetest__physicalplantest__physical_plan.tb.id, funcs:sum(Column#19)->Column#13, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.tb.id)->planner__core__casetest__physicalplantest__physical_plan.tb.id + └─TableReader 7992.00 root data:HashAgg + └─HashAgg 7992.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.tb.id, funcs:sum(planner__core__casetest__physicalplantest__physical_plan.tb.code)->Column#19 + └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tb.id)) + └─TableFullScan 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo +SELECT ta.NAME,(SELECT sum(tb.CODE) FROM tb WHERE ta.id = tb.id) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +NAME tb_sum_code +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.NAME,(SELECT /*+ no_decorrelate() */ sum(tb.CODE) FROM tb WHERE ta.id = tb.id) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +id estRows task access object operator info +Projection 250.00 root planner__core__casetest__physicalplantest__physical_plan.ta.name, Column#13 +└─Apply 250.00 root CARTESIAN left outer join + ├─TableReader(Build) 250.00 root data:Selection + │ └─Selection 250.00 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.ta.name, "chad999%", 92) + │ └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo + └─MaxOneRow(Probe) 250.00 root + └─StreamAgg 250.00 root funcs:sum(Column#21)->Column#13 + └─Projection 2500.00 root cast(planner__core__casetest__physicalplantest__physical_plan.tb.code, decimal(10,0) BINARY)->Column#21 + └─IndexLookUp 2500.00 root + ├─IndexRangeScan(Build) 2500.00 cop[tikv] table:tb, index:idx_tb_id(id) range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.tb.id)], keep order:false, stats:pseudo + └─TableRowIDScan(Probe) 2500.00 cop[tikv] table:tb keep order:false, stats:pseudo +SELECT ta.NAME,(SELECT /*+ no_decorrelate() */ sum(tb.CODE) FROM tb WHERE ta.id = tb.id) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +NAME tb_sum_code +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.NAME,(SELECT sum(tb.CODE) FROM tb WHERE ta.id = tb.id and exists (select 1 from tc where tb.name=tc.name and tc.`code` like '999%')) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +id estRows task access object operator info +HashJoin 250.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.tb.id)] +├─TableReader(Build) 250.00 root data:Selection +│ └─Selection 250.00 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.ta.name, "chad999%", 92) +│ └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo +└─HashAgg(Probe) 6387.21 root group by:Column#39, funcs:sum(Column#37)->Column#18, funcs:firstrow(Column#38)->planner__core__casetest__physicalplantest__physical_plan.tb.id + └─Projection 7984.01 root cast(planner__core__casetest__physicalplantest__physical_plan.tb.code, decimal(10,0) BINARY)->Column#37, planner__core__casetest__physicalplantest__physical_plan.tb.id->Column#38, planner__core__casetest__physicalplantest__physical_plan.tb.id->Column#39 + └─HashJoin 7984.01 root semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.tb.name, planner__core__casetest__physicalplantest__physical_plan.tc.name)] + ├─TableReader(Build) 7992.00 root data:Selection + │ └─Selection 7992.00 cop[tikv] like(cast(planner__core__casetest__physicalplantest__physical_plan.tc.code, var_string(20)), "999%", 92), not(isnull(planner__core__casetest__physicalplantest__physical_plan.tc.name)) + │ └─TableFullScan 10000.00 cop[tikv] table:tc 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.tb.id)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.tb.name)) + └─TableFullScan 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo +SELECT ta.NAME,(SELECT sum(tb.CODE) FROM tb WHERE ta.id = tb.id and exists (select 1 from tc where tb.name=tc.name and tc.`code` like '999%')) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +NAME tb_sum_code +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.NAME,(SELECT /*+ no_decorrelate() */ sum(tb.CODE) FROM tb WHERE ta.id = tb.id and exists (select 1 from tc where tb.name=tc.name and tc.`code` like '999%')) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +id estRows task access object operator info +Projection 250.00 root planner__core__casetest__physicalplantest__physical_plan.ta.name, Column#18 +└─Apply 250.00 root CARTESIAN left outer join + ├─TableReader(Build) 250.00 root data:Selection + │ └─Selection 250.00 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.ta.name, "chad999%", 92) + │ └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo + └─MaxOneRow(Probe) 250.00 root + └─StreamAgg 250.00 root funcs:sum(Column#33)->Column#18 + └─Projection 1998.00 root cast(planner__core__casetest__physicalplantest__physical_plan.tb.code, decimal(10,0) BINARY)->Column#33 + └─IndexHashJoin 1998.00 root semi join, inner:IndexLookUp, outer key:planner__core__casetest__physicalplantest__physical_plan.tb.name, inner key:planner__core__casetest__physicalplantest__physical_plan.tc.name, equal cond:eq(planner__core__casetest__physicalplantest__physical_plan.tb.name, planner__core__casetest__physicalplantest__physical_plan.tc.name) + ├─IndexLookUp(Build) 2497.50 root + │ ├─IndexRangeScan(Build) 2500.00 cop[tikv] table:tb, index:idx_tb_id(id) range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.tb.id)], keep order:false, stats:pseudo + │ └─Selection(Probe) 2497.50 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tb.name)) + │ └─TableRowIDScan 2500.00 cop[tikv] table:tb keep order:false, stats:pseudo + └─IndexLookUp(Probe) 3121.87 root + ├─Selection(Build) 3902.34 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tc.name)) + │ └─IndexRangeScan 3906.25 cop[tikv] table:tc, index:idx_tc_name(name) range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.tc.name, planner__core__casetest__physicalplantest__physical_plan.tb.name)], keep order:false, stats:pseudo + └─Selection(Probe) 3121.87 cop[tikv] like(cast(planner__core__casetest__physicalplantest__physical_plan.tc.code, var_string(20)), "999%", 92) + └─TableRowIDScan 3902.34 cop[tikv] table:tc keep order:false, stats:pseudo +SELECT ta.NAME,(SELECT /*+ no_decorrelate() */ sum(tb.CODE) FROM tb WHERE ta.id = tb.id and exists (select 1 from tc where tb.name=tc.name and tc.`code` like '999%')) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +NAME tb_sum_code +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.NAME,(SELECT sum(tb.CODE) FROM tb WHERE ta.id = tb.id and exists (select /*+ no_decorrelate() */ 1 from tc where tb.name=tc.name and tc.`code` like '999%')) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +id estRows task access object operator info +HashJoin 250.00 root left outer join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.tb.id)] +├─TableReader(Build) 250.00 root data:Selection +│ └─Selection 250.00 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.ta.name, "chad999%", 92) +│ └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo +└─HashAgg(Probe) 7992.00 root group by:Column#28, funcs:sum(Column#26)->Column#18, funcs:firstrow(Column#27)->planner__core__casetest__physicalplantest__physical_plan.tb.id + └─Projection 9990.00 root cast(planner__core__casetest__physicalplantest__physical_plan.tb.code, decimal(10,0) BINARY)->Column#26, planner__core__casetest__physicalplantest__physical_plan.tb.id->Column#27, planner__core__casetest__physicalplantest__physical_plan.tb.id->Column#28 + └─Apply 9990.00 root CARTESIAN semi join + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tb.id)) + │ └─TableFullScan 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo + └─IndexLookUp(Probe) 79920.00 root + ├─IndexRangeScan(Build) 99900.00 cop[tikv] table:tc, index:idx_tc_name(name) range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.tb.name, planner__core__casetest__physicalplantest__physical_plan.tc.name)], keep order:false, stats:pseudo + └─Selection(Probe) 79920.00 cop[tikv] like(cast(planner__core__casetest__physicalplantest__physical_plan.tc.code, var_string(20)), "999%", 92) + └─TableRowIDScan 99900.00 cop[tikv] table:tc keep order:false, stats:pseudo +SELECT ta.NAME,(SELECT sum(tb.CODE) FROM tb WHERE ta.id = tb.id and exists (select /*+ no_decorrelate() */ 1 from tc where tb.name=tc.name and tc.`code` like '999%')) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +NAME tb_sum_code +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.NAME,(SELECT /*+ no_decorrelate() */ sum(tb.CODE) FROM tb WHERE ta.id = tb.id and exists (select /*+ no_decorrelate() */ 1 from tc where tb.name=tc.name and tc.`code` like '999%')) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +id estRows task access object operator info +Projection 250.00 root planner__core__casetest__physicalplantest__physical_plan.ta.name, Column#18 +└─Apply 250.00 root CARTESIAN left outer join + ├─TableReader(Build) 250.00 root data:Selection + │ └─Selection 250.00 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.ta.name, "chad999%", 92) + │ └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo + └─MaxOneRow(Probe) 250.00 root + └─StreamAgg 250.00 root funcs:sum(Column#22)->Column#18 + └─Projection 2500.00 root cast(planner__core__casetest__physicalplantest__physical_plan.tb.code, decimal(10,0) BINARY)->Column#22 + └─Apply 2500.00 root CARTESIAN semi join + ├─IndexLookUp(Build) 2500.00 root + │ ├─IndexRangeScan(Build) 2500.00 cop[tikv] table:tb, index:idx_tb_id(id) range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.tb.id)], keep order:false, stats:pseudo + │ └─TableRowIDScan(Probe) 2500.00 cop[tikv] table:tb keep order:false, stats:pseudo + └─IndexLookUp(Probe) 20000.00 root + ├─IndexRangeScan(Build) 25000.00 cop[tikv] table:tc, index:idx_tc_name(name) range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.tb.name, planner__core__casetest__physicalplantest__physical_plan.tc.name)], keep order:false, stats:pseudo + └─Selection(Probe) 20000.00 cop[tikv] like(cast(planner__core__casetest__physicalplantest__physical_plan.tc.code, var_string(20)), "999%", 92) + └─TableRowIDScan 25000.00 cop[tikv] table:tc keep order:false, stats:pseudo +SELECT ta.NAME,(SELECT /*+ no_decorrelate() */ sum(tb.CODE) FROM tb WHERE ta.id = tb.id and exists (select /*+ no_decorrelate() */ 1 from tc where tb.name=tc.name and tc.`code` like '999%')) tb_sum_code FROM ta WHERE ta.NAME LIKE 'chad999%'; +NAME tb_sum_code +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.id, 'split' as flag FROM ta WHERE ta.NAME ='chad999' and (select max(tb.code) from tb where ta.id=tb.id ) > 900; +id estRows task access object operator info +Projection 9.99 root planner__core__casetest__physicalplantest__physical_plan.ta.id, split->Column#10 +└─HashJoin 9.99 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.tb.id)] + ├─IndexLookUp(Build) 9.99 root + │ ├─IndexRangeScan(Build) 10.00 cop[tikv] table:ta, index:idx_ta_name(name) range:["chad999","chad999"], keep order:false, stats:pseudo + │ └─Selection(Probe) 9.99 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.ta.id)) + │ └─TableRowIDScan 10.00 cop[tikv] table:ta keep order:false, stats:pseudo + └─Selection(Probe) 6393.60 root gt(Column#9, 900) + └─HashAgg 7992.00 root group by:planner__core__casetest__physicalplantest__physical_plan.tb.id, funcs:max(Column#19)->Column#9, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.tb.id)->planner__core__casetest__physicalplantest__physical_plan.tb.id + └─TableReader 7992.00 root data:HashAgg + └─HashAgg 7992.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.tb.id, funcs:max(planner__core__casetest__physicalplantest__physical_plan.tb.code)->Column#19 + └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tb.id)) + └─TableFullScan 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo +SELECT ta.id, 'split' as flag FROM ta WHERE ta.NAME ='chad999' and (select max(tb.code) from tb where ta.id=tb.id ) > 900; +id flag +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.id, 'split' as flag FROM ta WHERE ta.NAME ='chad999' and (select /*+ no_decorrelate() */ max(tb.code) from tb where ta.id=tb.id ) > 900; +id estRows task access object operator info +Projection 10.00 root planner__core__casetest__physicalplantest__physical_plan.ta.id, split->Column#10 +└─Apply 10.00 root CARTESIAN inner join + ├─IndexLookUp(Build) 10.00 root + │ ├─IndexRangeScan(Build) 10.00 cop[tikv] table:ta, index:idx_ta_name(name) range:["chad999","chad999"], keep order:false, stats:pseudo + │ └─TableRowIDScan(Probe) 10.00 cop[tikv] table:ta keep order:false, stats:pseudo + └─Selection(Probe) 8.00 root gt(Column#9, 900) + └─MaxOneRow 10.00 root + └─StreamAgg 10.00 root funcs:max(planner__core__casetest__physicalplantest__physical_plan.tb.code)->Column#9 + └─TopN 10.00 root planner__core__casetest__physicalplantest__physical_plan.tb.code:desc, offset:0, count:1 + └─IndexLookUp 10.00 root + ├─IndexRangeScan(Build) 100.00 cop[tikv] table:tb, index:idx_tb_id(id) range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.tb.id)], keep order:false, stats:pseudo + └─TopN(Probe) 10.00 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.tb.code:desc, offset:0, count:1 + └─Selection 99.90 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tb.code)) + └─TableRowIDScan 100.00 cop[tikv] table:tb keep order:false, stats:pseudo +SELECT ta.id, 'split' as flag FROM ta WHERE ta.NAME ='chad999' and (select /*+ no_decorrelate() */ max(tb.code) from tb where ta.id=tb.id ) > 900; +id flag +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.NAME FROM ta WHERE EXISTS (select 1 from tb where ta.code = tb.code and tb.NAME LIKE 'chad9%') AND (select max(id) from tc where ta.name=tc.name and tc.name like 'chad99%') > 100 and (select max(id) from td where ta.id=td.id and td.name like 'chad999%') > 100; +id estRows task access object operator info +HashJoin 159.84 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.td.id)] +├─Selection(Build) 159.84 root gt(Column#19, 100) +│ └─HashAgg 199.80 root group by:planner__core__casetest__physicalplantest__physical_plan.td.id, funcs:max(Column#32)->Column#19, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.td.id)->planner__core__casetest__physicalplantest__physical_plan.td.id +│ └─TableReader 199.80 root data:HashAgg +│ └─HashAgg 199.80 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.td.id, funcs:max(planner__core__casetest__physicalplantest__physical_plan.td.id)->Column#32 +│ └─Selection 249.75 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.td.name, "chad999%", 92), not(isnull(planner__core__casetest__physicalplantest__physical_plan.td.id)) +│ └─TableFullScan 10000.00 cop[tikv] table:td keep order:false, stats:pseudo +└─HashJoin(Probe) 200.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.ta.name, planner__core__casetest__physicalplantest__physical_plan.tc.name)] + ├─Selection(Build) 160.00 root gt(Column#14, 100) + │ └─HashAgg 200.00 root group by:planner__core__casetest__physicalplantest__physical_plan.tc.name, funcs:max(Column#24)->Column#14, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.tc.name)->planner__core__casetest__physicalplantest__physical_plan.tc.name + │ └─TableReader 200.00 root data:HashAgg + │ └─HashAgg 200.00 cop[tikv] group by:planner__core__casetest__physicalplantest__physical_plan.tc.name, funcs:max(planner__core__casetest__physicalplantest__physical_plan.tc.id)->Column#24 + │ └─Selection 250.00 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.tc.name, "chad99%", 92), not(isnull(planner__core__casetest__physicalplantest__physical_plan.tc.name)) + │ └─TableFullScan 10000.00 cop[tikv] table:tc keep order:false, stats:pseudo + └─HashJoin(Probe) 7976.02 root semi join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.ta.code, planner__core__casetest__physicalplantest__physical_plan.tb.code)] + ├─TableReader(Build) 249.75 root data:Selection + │ └─Selection 249.75 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.tb.name, "chad9%", 92), not(isnull(planner__core__casetest__physicalplantest__physical_plan.tb.code)) + │ └─TableFullScan 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo + └─TableReader(Probe) 9970.03 root data:Selection + └─Selection 9970.03 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.ta.code)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.ta.id)), not(isnull(planner__core__casetest__physicalplantest__physical_plan.ta.name)) + └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo +SELECT ta.NAME FROM ta WHERE EXISTS (select 1 from tb where ta.code = tb.code and tb.NAME LIKE 'chad9%') AND (select max(id) from tc where ta.name=tc.name and tc.name like 'chad99%') > 100 and (select max(id) from td where ta.id=td.id and td.name like 'chad999%') > 100; +NAME +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.NAME FROM ta WHERE EXISTS (select /*+ semi_join_rewrite() */ 1 from tb where ta.code = tb.code and tb.NAME LIKE 'chad9%') AND (select /*+ no_decorrelate() */ max(id) from tc where ta.name=tc.name and tc.name like 'chad99%') > 100 and (select /*+ no_decorrelate() */ max(id) from td where ta.id=td.id and td.name like 'chad999%') > 100; +id estRows task access object operator info +Projection 249.75 root planner__core__casetest__physicalplantest__physical_plan.ta.name +└─Apply 249.75 root CARTESIAN inner join + ├─Apply(Build) 249.75 root CARTESIAN inner join + │ ├─IndexHashJoin(Build) 249.75 root inner join, inner:IndexLookUp, outer key:planner__core__casetest__physicalplantest__physical_plan.tb.code, inner key:planner__core__casetest__physicalplantest__physical_plan.ta.code, equal cond:eq(planner__core__casetest__physicalplantest__physical_plan.tb.code, planner__core__casetest__physicalplantest__physical_plan.ta.code) + │ │ ├─HashAgg(Build) 199.80 root group by:planner__core__casetest__physicalplantest__physical_plan.tb.code, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.tb.code)->planner__core__casetest__physicalplantest__physical_plan.tb.code + │ │ │ └─TableReader 249.75 root data:Selection + │ │ │ └─Selection 249.75 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.tb.name, "chad9%", 92), not(isnull(planner__core__casetest__physicalplantest__physical_plan.tb.code)) + │ │ │ └─TableFullScan 10000.00 cop[tikv] table:tb keep order:false, stats:pseudo + │ │ └─IndexLookUp(Probe) 249.75 root + │ │ ├─Selection(Build) 249.75 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.ta.code)) + │ │ │ └─IndexRangeScan 250.00 cop[tikv] table:ta, index:idx_ta_code(code) range: decided by [eq(planner__core__casetest__physicalplantest__physical_plan.ta.code, planner__core__casetest__physicalplantest__physical_plan.tb.code)], keep order:false, stats:pseudo + │ │ └─TableRowIDScan(Probe) 249.75 cop[tikv] table:ta keep order:false, stats:pseudo + │ └─Selection(Probe) 199.80 root gt(Column#14, 100) + │ └─MaxOneRow 249.75 root + │ └─StreamAgg 249.75 root funcs:max(planner__core__casetest__physicalplantest__physical_plan.tc.id)->Column#14 + │ └─TopN 62.38 root planner__core__casetest__physicalplantest__physical_plan.tc.id:desc, offset:0, count:1 + │ └─IndexLookUp 62.38 root + │ ├─Selection(Build) 62.38 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.ta.name, planner__core__casetest__physicalplantest__physical_plan.tc.name), like(planner__core__casetest__physicalplantest__physical_plan.tc.name, "chad99%", 92) + │ │ └─IndexRangeScan 62437.50 cop[tikv] table:tc, index:idx_tc_name(name) range:["chad99","chad9:"), keep order:false, stats:pseudo + │ └─TopN(Probe) 62.38 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.tc.id:desc, offset:0, count:1 + │ └─Selection 62.38 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tc.id)) + │ └─TableRowIDScan 62.38 cop[tikv] table:tc keep order:false, stats:pseudo + └─Selection(Probe) 199.80 root gt(Column#19, 100) + └─MaxOneRow 249.75 root + └─StreamAgg 249.75 root funcs:max(planner__core__casetest__physicalplantest__physical_plan.td.id)->Column#19 + └─TopN 62.38 root planner__core__casetest__physicalplantest__physical_plan.td.id:desc, offset:0, count:1 + └─IndexLookUp 62.38 root + ├─Selection(Build) 1560.94 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.td.name, "chad999%", 92) + │ └─IndexRangeScan 62437.50 cop[tikv] table:td, index:idx_tc_name(name) range:["chad999","chad99:"), keep order:false, stats:pseudo + └─TopN(Probe) 62.38 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.td.id:desc, offset:0, count:1 + └─Selection 62.38 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.td.id), not(isnull(planner__core__casetest__physicalplantest__physical_plan.td.id)) + └─TableRowIDScan 1560.94 cop[tikv] table:td keep order:false, stats:pseudo +SELECT ta.NAME FROM ta WHERE EXISTS (select /*+ semi_join_rewrite() */ 1 from tb where ta.code = tb.code and tb.NAME LIKE 'chad9%') AND (select /*+ no_decorrelate() */ max(id) from tc where ta.name=tc.name and tc.name like 'chad99%') > 100 and (select /*+ no_decorrelate() */ max(id) from td where ta.id=td.id and td.name like 'chad999%') > 100; +NAME +show warnings; +Level Code Message +explain format = 'brief' SELECT ta.NAME FROM ta WHERE EXISTS (select /*+ no_decorrelate() */ 1 from tb where ta.code = tb.code and tb.NAME LIKE 'chad9%') AND (select /*+ no_decorrelate() */ max(id) from tc where ta.name=tc.name and tc.name like 'chad99%') > 100 and (select /*+ no_decorrelate() */ max(id) from td where ta.id=td.id and td.name like 'chad999%') > 100; +id estRows task access object operator info +Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.ta.name +└─Apply 10000.00 root CARTESIAN inner join + ├─Apply(Build) 10000.00 root CARTESIAN inner join + │ ├─Apply(Build) 10000.00 root CARTESIAN semi join + │ │ ├─TableReader(Build) 10000.00 root data:TableFullScan + │ │ │ └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo + │ │ └─IndexLookUp(Probe) 2500.00 root + │ │ ├─Selection(Build) 62500.00 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.tb.name, "chad9%", 92) + │ │ │ └─IndexRangeScan 2500000.00 cop[tikv] table:tb, index:idx_tb_name(name) range:["chad9","chad:"), keep order:false, stats:pseudo + │ │ └─Selection(Probe) 2500.00 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.ta.code, planner__core__casetest__physicalplantest__physical_plan.tb.code) + │ │ └─TableRowIDScan 62500.00 cop[tikv] table:tb keep order:false, stats:pseudo + │ └─Selection(Probe) 8000.00 root gt(Column#14, 100) + │ └─MaxOneRow 10000.00 root + │ └─StreamAgg 10000.00 root funcs:max(planner__core__casetest__physicalplantest__physical_plan.tc.id)->Column#14 + │ └─TopN 2497.50 root planner__core__casetest__physicalplantest__physical_plan.tc.id:desc, offset:0, count:1 + │ └─IndexLookUp 2497.50 root + │ ├─Selection(Build) 2497.50 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.ta.name, planner__core__casetest__physicalplantest__physical_plan.tc.name), like(planner__core__casetest__physicalplantest__physical_plan.tc.name, "chad99%", 92) + │ │ └─IndexRangeScan 2500000.00 cop[tikv] table:tc, index:idx_tc_name(name) range:["chad99","chad9:"), keep order:false, stats:pseudo + │ └─TopN(Probe) 2497.50 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.tc.id:desc, offset:0, count:1 + │ └─Selection 2497.50 cop[tikv] not(isnull(planner__core__casetest__physicalplantest__physical_plan.tc.id)) + │ └─TableRowIDScan 2497.50 cop[tikv] table:tc keep order:false, stats:pseudo + └─Selection(Probe) 8000.00 root gt(Column#19, 100) + └─MaxOneRow 10000.00 root + └─StreamAgg 10000.00 root funcs:max(planner__core__casetest__physicalplantest__physical_plan.td.id)->Column#19 + └─TopN 2497.50 root planner__core__casetest__physicalplantest__physical_plan.td.id:desc, offset:0, count:1 + └─IndexLookUp 2497.50 root + ├─Selection(Build) 62500.00 cop[tikv] like(planner__core__casetest__physicalplantest__physical_plan.td.name, "chad999%", 92) + │ └─IndexRangeScan 2500000.00 cop[tikv] table:td, index:idx_tc_name(name) range:["chad999","chad99:"), keep order:false, stats:pseudo + └─TopN(Probe) 2497.50 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.td.id:desc, offset:0, count:1 + └─Selection 2497.50 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.ta.id, planner__core__casetest__physicalplantest__physical_plan.td.id), not(isnull(planner__core__casetest__physicalplantest__physical_plan.td.id)) + └─TableRowIDScan 62500.00 cop[tikv] table:td keep order:false, stats:pseudo +SELECT ta.NAME FROM ta WHERE EXISTS (select /*+ no_decorrelate() */ 1 from tb where ta.code = tb.code and tb.NAME LIKE 'chad9%') AND (select /*+ no_decorrelate() */ max(id) from tc where ta.name=tc.name and tc.name like 'chad99%') > 100 and (select /*+ no_decorrelate() */ max(id) from td where ta.id=td.id and td.name like 'chad999%') > 100; +NAME +show warnings; +Level Code Message +set tidb_cost_model_version=DEFAULT; +drop table if exists t, t_pick_row_id; +set tidb_cost_model_version=1; +create table t (a int(11) not null, b varchar(10) not null, c date not null, d char(1) not null, e bigint not null, f datetime not null, g bool not null, h bool ); +create table t_pick_row_id (a char(20) not null); +explain format = 'brief' select count(*) from t; +id estRows task access object operator info +StreamAgg 1.00 root funcs:count(Column#12)->Column#10 +└─TableReader 1.00 root data:StreamAgg + └─StreamAgg 1.00 cop[tikv] funcs:count(1)->Column#12 + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +explain format = 'brief' select count(1), count(3.1415), count(0), count(null) from t -- shouldn't be rewritten; +id estRows task access object operator info +StreamAgg 1.00 root funcs:count(Column#18)->Column#10, funcs:count(Column#19)->Column#11, funcs:count(Column#20)->Column#12, funcs:count(Column#21)->Column#13 +└─TableReader 1.00 root data:StreamAgg + └─StreamAgg 1.00 cop[tikv] funcs:count(1)->Column#18, funcs:count(3.1415)->Column#19, funcs:count(0)->Column#20, funcs:count(NULL)->Column#21 + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +explain format = 'brief' select count(*) from t where a=1; +id estRows task access object operator info +StreamAgg 1.00 root funcs:count(Column#12)->Column#10 +└─TableReader 1.00 root data:StreamAgg + └─StreamAgg 1.00 cop[tikv] funcs:count(1)->Column#12 + └─Selection 10.00 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t.a, 1) + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +explain format = 'brief' select count(*) from t_pick_row_id; +id estRows task access object operator info +StreamAgg 1.00 root funcs:count(Column#5)->Column#3 +└─TableReader 1.00 root data:StreamAgg + └─StreamAgg 1.00 cop[tikv] funcs:count(1)->Column#5 + └─TableFullScan 10000.00 cop[tikv] table:t_pick_row_id keep order:false, stats:pseudo +explain format = 'brief' select t.b, t.c from (select count(*) as c from t) a, t where a.c=t.a -- shouldn't be rewritten; +id estRows task access object operator info +HashJoin 1.25 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t.a, Column#10)] +├─StreamAgg(Build) 1.00 root funcs:count(Column#21)->Column#10 +│ └─TableReader 1.00 root data:StreamAgg +│ └─StreamAgg 1.00 cop[tikv] funcs:count(1)->Column#21 +│ └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +└─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +explain format = 'brief' select * from t outTable where outTable.a > (select count(*) from t inn where inn.a = outTable.b) -- shouldn't be rewritten; +id estRows task access object operator info +Projection 10000.00 root planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.b, planner__core__casetest__physicalplantest__physical_plan.t.c, planner__core__casetest__physicalplantest__physical_plan.t.d, planner__core__casetest__physicalplantest__physical_plan.t.e, planner__core__casetest__physicalplantest__physical_plan.t.f, planner__core__casetest__physicalplantest__physical_plan.t.g, planner__core__casetest__physicalplantest__physical_plan.t.h +└─Apply 10000.00 root CARTESIAN inner join, other cond:gt(planner__core__casetest__physicalplantest__physical_plan.t.a, Column#19) + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:outTable keep order:false, stats:pseudo + └─StreamAgg(Probe) 10000.00 root funcs:count(Column#21)->Column#19 + └─TableReader 10000.00 root data:StreamAgg + └─StreamAgg 10000.00 cop[tikv] funcs:count(1)->Column#21 + └─Selection 80000000.00 cop[tikv] eq(cast(planner__core__casetest__physicalplantest__physical_plan.t.a, double BINARY), cast(planner__core__casetest__physicalplantest__physical_plan.t.b, double BINARY)) + └─TableFullScan 100000000.00 cop[tikv] table:inn keep order:false, stats:pseudo +explain format = 'brief' select count(*) from t t1, t t2 where t1.a=t2.e -- shouldn't be rewritten; +id estRows task access object operator info +HashAgg 1.00 root funcs:count(1)->Column#19 +└─HashJoin 12500.00 root inner join, equal:[eq(planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.e)] + ├─TableReader(Build) 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select count(distinct 1) from t -- shouldn't be rewritten; +id estRows task access object operator info +StreamAgg 1.00 root funcs:count(distinct 1)->Column#10 +└─TableReader 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +explain format = 'brief' select count(1), count(a), count(b) from t -- shouldn't be rewritten; +id estRows task access object operator info +StreamAgg 1.00 root funcs:count(Column#16)->Column#10, funcs:count(Column#17)->Column#11, funcs:count(Column#18)->Column#12 +└─TableReader 1.00 root data:StreamAgg + └─StreamAgg 1.00 cop[tikv] funcs:count(1)->Column#16, funcs:count(planner__core__casetest__physicalplantest__physical_plan.t.a)->Column#17, funcs:count(planner__core__casetest__physicalplantest__physical_plan.t.b)->Column#18 + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +explain format = 'brief' select a, count(*) from t group by a -- shouldn't be rewritten; +id estRows task access object operator info +Projection 8000.00 root planner__core__casetest__physicalplantest__physical_plan.t.a, Column#10 +└─HashAgg 8000.00 root group by:planner__core__casetest__physicalplantest__physical_plan.t.a, funcs:count(1)->Column#10, funcs:firstrow(planner__core__casetest__physicalplantest__physical_plan.t.a)->planner__core__casetest__physicalplantest__physical_plan.t.a + └─TableReader 10000.00 root data:TableFullScan + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +explain format = 'brief' select sum(a) from t -- sum shouldn't be rewritten; +id estRows task access object operator info +StreamAgg 1.00 root funcs:sum(Column#12)->Column#10 +└─TableReader 1.00 root data:StreamAgg + └─StreamAgg 1.00 cop[tikv] funcs:sum(planner__core__casetest__physicalplantest__physical_plan.t.a)->Column#12 + └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo +set tidb_cost_model_version=DEFAULT; +drop table if exists t, tcommon, thash; +set tidb_cost_model_version=1; +create table t (a int, b int, c int, index idx(a, c), index idx2(b, c)); +create table tcommon (a int, b int, c int, primary key(a, c), index idx2(b, c)); +create table thash(a int, b int, c int, index idx_ac(a, c), index idx_bc(b, c)) PARTITION BY HASH (`a`) PARTITIONS 4; +explain format = 'brief' select * from t where a = 1 or b = 1 order by c limit 2; +id estRows task access object operator info +Projection 2.00 root planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.b, planner__core__casetest__physicalplantest__physical_plan.t.c +└─IndexMerge 2.00 root type: union, limit embedded(offset:0, count:2) + ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 1.00 cop[tikv] table:t, index:idx(a, c) range:[1,1], keep order:true, stats:pseudo + ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 1.00 cop[tikv] table:t, index:idx2(b, c) range:[1,1], keep order:true, stats:pseudo + └─TableRowIDScan(Probe) 2.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from t where a = 1 or b in (1, 2, 3) order by c limit 2; +id estRows task access object operator info +TopN 2.00 root planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 +└─IndexMerge 2.00 root type: union + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:idx(a, c) range:[1,1], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 30.00 cop[tikv] table:t, index:idx2(b, c) range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo + └─TopN(Probe) 2.00 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 + └─TableRowIDScan 39.97 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from t where a in (1, 2, 3) or b = 1 order by c limit 2; +id estRows task access object operator info +TopN 2.00 root planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 +└─IndexMerge 2.00 root type: union + ├─IndexRangeScan(Build) 30.00 cop[tikv] table:t, index:idx(a, c) range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:idx2(b, c) range:[1,1], keep order:false, stats:pseudo + └─TopN(Probe) 2.00 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 + └─TableRowIDScan 39.97 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from t where a in (1, 2, 3) or b in (1, 2, 3) order by c limit 2; +id estRows task access object operator info +TopN 2.00 root planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 +└─IndexMerge 2.00 root type: union + ├─IndexRangeScan(Build) 30.00 cop[tikv] table:t, index:idx(a, c) range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 30.00 cop[tikv] table:t, index:idx2(b, c) range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo + └─TopN(Probe) 2.00 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 + └─TableRowIDScan 59.91 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from t where (a = 1 and c = 2) or (b = 1) order by c limit 2; +id estRows task access object operator info +Projection 2.00 root planner__core__casetest__physicalplantest__physical_plan.t.a, planner__core__casetest__physicalplantest__physical_plan.t.b, planner__core__casetest__physicalplantest__physical_plan.t.c +└─IndexMerge 2.00 root type: union, limit embedded(offset:0, count:2) + ├─Limit(Build) 0.02 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 0.02 cop[tikv] table:t, index:idx(a, c) range:[1 2,1 2], keep order:true, stats:pseudo + ├─Limit(Build) 1.98 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 1.98 cop[tikv] table:t, index:idx2(b, c) range:[1,1], keep order:true, stats:pseudo + └─TableRowIDScan(Probe) 2.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from t where (a = 1 and c = 2) or b in (1, 2, 3) order by c limit 2; +id estRows task access object operator info +TopN 2.00 root planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 +└─IndexMerge 2.00 root type: union + ├─IndexRangeScan(Build) 0.10 cop[tikv] table:t, index:idx(a, c) range:[1 2,1 2], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 30.00 cop[tikv] table:t, index:idx2(b, c) range:[1,1], [2,2], [3,3], keep order:false, stats:pseudo + └─TopN(Probe) 2.00 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 + └─TableRowIDScan 30.10 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from t where (a = 1 and c = 2) or (b in (1, 2, 3) and c = 3) order by c limit 2; +id estRows task access object operator info +TopN 0.40 root planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 +└─IndexMerge 0.40 root type: union + ├─IndexRangeScan(Build) 0.10 cop[tikv] table:t, index:idx(a, c) range:[1 2,1 2], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 0.30 cop[tikv] table:t, index:idx2(b, c) range:[1 3,1 3], [2 3,2 3], [3 3,3 3], keep order:false, stats:pseudo + └─TopN(Probe) 0.40 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 + └─TableRowIDScan 0.40 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from t where (a = 1 or b = 2) and c = 3 order by c limit 2; +id estRows task access object operator info +TopN 0.02 root planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 +└─IndexMerge 0.02 root type: union + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:idx(a, c) range:[1,1], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:idx2(b, c) range:[2,2], keep order:false, stats:pseudo + └─TopN(Probe) 0.02 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 + └─Selection 0.02 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t.c, 3) + └─TableRowIDScan 19.99 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from t where (a = 1 or b = 2) and c in (1, 2, 3) order by c limit 2; +id estRows task access object operator info +TopN 0.06 root planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 +└─IndexMerge 0.06 root type: union + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:idx(a, c) range:[1,1], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:idx2(b, c) range:[2,2], keep order:false, stats:pseudo + └─TopN(Probe) 0.06 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.t.c, offset:0, count:2 + └─Selection 0.06 cop[tikv] in(planner__core__casetest__physicalplantest__physical_plan.t.c, 1, 2, 3) + └─TableRowIDScan 19.99 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from t where (a = 1 or b = 2) and c in (1, 2, 3) order by b limit 2; +id estRows task access object operator info +TopN 0.06 root planner__core__casetest__physicalplantest__physical_plan.t.b, offset:0, count:2 +└─IndexMerge 0.06 root type: union + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:idx(a, c) range:[1,1], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:idx2(b, c) range:[2,2], keep order:false, stats:pseudo + └─TopN(Probe) 0.06 cop[tikv] planner__core__casetest__physicalplantest__physical_plan.t.b, offset:0, count:2 + └─Selection 0.06 cop[tikv] in(planner__core__casetest__physicalplantest__physical_plan.t.c, 1, 2, 3) + └─TableRowIDScan 19.99 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from tcommon where a = 1 or b = 1 order by c limit 2; +id estRows task access object operator info +Projection 2.00 root planner__core__casetest__physicalplantest__physical_plan.tcommon.a, planner__core__casetest__physicalplantest__physical_plan.tcommon.b, planner__core__casetest__physicalplantest__physical_plan.tcommon.c +└─IndexMerge 2.00 root type: union, limit embedded(offset:0, count:2) + ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 1.00 cop[tikv] table:tcommon, index:PRIMARY(a, c) range:[1,1], keep order:true, stats:pseudo + ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 1.00 cop[tikv] table:tcommon, index:idx2(b, c) range:[1,1], keep order:true, stats:pseudo + └─TableRowIDScan(Probe) 2.00 cop[tikv] table:tcommon keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from tcommon where (a = 1 and c = 2) or (b = 1) order by c limit 2; +id estRows task access object operator info +Projection 2.00 root planner__core__casetest__physicalplantest__physical_plan.tcommon.a, planner__core__casetest__physicalplantest__physical_plan.tcommon.b, planner__core__casetest__physicalplantest__physical_plan.tcommon.c +└─IndexMerge 2.00 root type: union, limit embedded(offset:0, count:2) + ├─Limit(Build) 0.18 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 0.18 cop[tikv] table:tcommon, index:PRIMARY(a, c) range:[1 2,1 2], keep order:true, stats:pseudo + ├─Limit(Build) 1.82 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 1.82 cop[tikv] table:tcommon, index:idx2(b, c) range:[1,1], keep order:true, stats:pseudo + └─TableRowIDScan(Probe) 2.00 cop[tikv] table:tcommon keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select * from thash use index(idx_ac, idx_bc) where a = 1 or b = 1 order by c limit 2; +id estRows task access object operator info +TopN 2.00 root planner__core__casetest__physicalplantest__physical_plan.thash.c, offset:0, count:2 +└─PartitionUnion 8.00 root + ├─Projection 2.00 root planner__core__casetest__physicalplantest__physical_plan.thash.a, planner__core__casetest__physicalplantest__physical_plan.thash.b, planner__core__casetest__physicalplantest__physical_plan.thash.c + │ └─IndexMerge 2.00 root type: union, limit embedded(offset:0, count:2) + │ ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ │ └─IndexRangeScan 1.00 cop[tikv] table:thash, partition:p0, index:idx_ac(a, c) range:[1,1], keep order:true, stats:pseudo + │ ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ │ └─IndexRangeScan 1.00 cop[tikv] table:thash, partition:p0, index:idx_bc(b, c) range:[1,1], keep order:true, stats:pseudo + │ └─TableRowIDScan(Probe) 2.00 cop[tikv] table:thash, partition:p0 keep order:false, stats:pseudo + ├─Projection 2.00 root planner__core__casetest__physicalplantest__physical_plan.thash.a, planner__core__casetest__physicalplantest__physical_plan.thash.b, planner__core__casetest__physicalplantest__physical_plan.thash.c + │ └─IndexMerge 2.00 root type: union, limit embedded(offset:0, count:2) + │ ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ │ └─IndexRangeScan 1.00 cop[tikv] table:thash, partition:p1, index:idx_ac(a, c) range:[1,1], keep order:true, stats:pseudo + │ ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ │ └─IndexRangeScan 1.00 cop[tikv] table:thash, partition:p1, index:idx_bc(b, c) range:[1,1], keep order:true, stats:pseudo + │ └─TableRowIDScan(Probe) 2.00 cop[tikv] table:thash, partition:p1 keep order:false, stats:pseudo + ├─Projection 2.00 root planner__core__casetest__physicalplantest__physical_plan.thash.a, planner__core__casetest__physicalplantest__physical_plan.thash.b, planner__core__casetest__physicalplantest__physical_plan.thash.c + │ └─IndexMerge 2.00 root type: union, limit embedded(offset:0, count:2) + │ ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ │ └─IndexRangeScan 1.00 cop[tikv] table:thash, partition:p2, index:idx_ac(a, c) range:[1,1], keep order:true, stats:pseudo + │ ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ │ └─IndexRangeScan 1.00 cop[tikv] table:thash, partition:p2, index:idx_bc(b, c) range:[1,1], keep order:true, stats:pseudo + │ └─TableRowIDScan(Probe) 2.00 cop[tikv] table:thash, partition:p2 keep order:false, stats:pseudo + └─Projection 2.00 root planner__core__casetest__physicalplantest__physical_plan.thash.a, planner__core__casetest__physicalplantest__physical_plan.thash.b, planner__core__casetest__physicalplantest__physical_plan.thash.c + └─IndexMerge 2.00 root type: union, limit embedded(offset:0, count:2) + ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 1.00 cop[tikv] table:thash, partition:p3, index:idx_ac(a, c) range:[1,1], keep order:true, stats:pseudo + ├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 + │ └─IndexRangeScan 1.00 cop[tikv] table:thash, partition:p3, index:idx_bc(b, c) range:[1,1], keep order:true, stats:pseudo + └─TableRowIDScan(Probe) 2.00 cop[tikv] table:thash, partition:p3 keep order:false, stats:pseudo +show warnings; +Level Code Message +Warning 1105 disable dynamic pruning due to thash has no global stats +set tidb_cost_model_version=DEFAULT; +drop table if exists t, t2, t3; +set tidb_cost_model_version=1; +CREATE TABLE `t2` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL, `c` int(11) DEFAULT NULL, KEY `a` (`a`), KEY `b` (`b`)) ; +insert into t2 values(1,2,1),(2,1,1),(3,3,1); +create table t(a int, j json, index kj((cast(j as signed array)))); +insert into t values(1, '[1,2,3]'); +CREATE TABLE `t3` ( +`id` int(11) NOT NULL, +`aid` bigint(20) DEFAULT NULL, +`c1` varchar(255) DEFAULT NULL, +`c2` varchar(255) DEFAULT NULL, +`d` int(11) DEFAULT NULL, +PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */, +KEY `aid_c1` (`aid`,`c1`), +KEY `aid_c2` (`aid`,`c2`) +); +explain format = 'brief' select /*+ use_index_merge(t2, a, b) */ * from t2 where a=1 or b=1 and c=1 limit 2; +id estRows task access object operator info +Limit 2.00 root offset:0, count:2 +└─IndexMerge 0.00 root type: union + ├─IndexRangeScan(Build) 2.00 cop[tikv] table:t2, index:a(a) range:[1,1], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 2.00 cop[tikv] table:t2, index:b(b) range:[1,1], keep order:false, stats:pseudo + └─Limit(Probe) 0.00 cop[tikv] offset:0, count:2 + └─Selection 0.00 cop[tikv] or(eq(planner__core__casetest__physicalplantest__physical_plan.t2.a, 1), and(eq(planner__core__casetest__physicalplantest__physical_plan.t2.b, 1), eq(planner__core__casetest__physicalplantest__physical_plan.t2.c, 1))) + └─TableRowIDScan 3.99 cop[tikv] table:t2 keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select /*+ use_index_merge(t2, a, b) */ * from t2 where a=1 and b=1 and c=1 limit 2; +id estRows task access object operator info +Limit 0.00 root offset:0, count:2 +└─IndexMerge 0.01 root type: intersection + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t2, index:a(a) range:[1,1], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t2, index:b(b) range:[1,1], keep order:false, stats:pseudo + └─Limit(Probe) 0.01 cop[tikv] offset:0, count:2 + └─Selection 0.01 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t2.c, 1) + └─TableRowIDScan 0.01 cop[tikv] table:t2 keep order:false, stats:pseudo +show warnings; +Level Code Message +select /*+ use_index_merge(t2, a, b) */ * from t2 where a=1 and b=1 and c=1 limit 2; +a b c +show warnings; +Level Code Message +explain format = 'brief' select /*+ use_index_merge(t2, a, b) */ * from t2 where a=1 or b=1 limit 2; +id estRows task access object operator info +IndexMerge 2.00 root type: union, limit embedded(offset:0, count:2) +├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 +│ └─IndexRangeScan 1.00 cop[tikv] table:t2, index:a(a) range:[1,1], keep order:false, stats:pseudo +├─Limit(Build) 1.00 cop[tikv] offset:0, count:2 +│ └─IndexRangeScan 1.00 cop[tikv] table:t2, index:b(b) range:[1,1], keep order:false, stats:pseudo +└─TableRowIDScan(Probe) 2.00 cop[tikv] table:t2 keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select /*+ use_index_merge(t2, a, b) */ * from t2 where a=1 and b=1 limit 2; +id estRows task access object operator info +IndexMerge 0.01 root type: intersection, limit embedded(offset:0, count:2) +├─IndexRangeScan(Build) 10.00 cop[tikv] table:t2, index:a(a) range:[1,1], keep order:false, stats:pseudo +├─IndexRangeScan(Build) 10.00 cop[tikv] table:t2, index:b(b) range:[1,1], keep order:false, stats:pseudo +└─TableRowIDScan(Probe) 0.01 cop[tikv] table:t2 keep order:false, stats:pseudo +show warnings; +Level Code Message +select /*+ use_index_merge(t2, a, b) */ * from t2 where a=1 and b=1 limit 2; +a b c +show warnings; +Level Code Message +explain format = 'brief' select /*+ use_index(t, kj) */ * from t where (1 member of (j)) limit 1; +id estRows task access object operator info +IndexMerge 0.00 root type: union, limit embedded(offset:0, count:1) +├─Limit(Build) 0.00 cop[tikv] offset:0, count:1 +│ └─IndexRangeScan 0.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[1,1], keep order:false, stats:pseudo +└─TableRowIDScan(Probe) 0.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select /*+ use_index(t, kj) */ * from t where json_contains(j, '[1, 2, 3]') limit 1; +id estRows task access object operator info +IndexMerge 0.00 root type: intersection, limit embedded(offset:0, count:1) +├─IndexRangeScan(Build) 0.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[1,1], keep order:false, stats:pseudo +├─IndexRangeScan(Build) 0.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[2,2], keep order:false, stats:pseudo +├─IndexRangeScan(Build) 0.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[3,3], keep order:false, stats:pseudo +└─TableRowIDScan(Probe) 0.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select /*+ use_index(t, kj) */ * from t where json_overlaps(j, '[1, 2, 3]') limit 1; +id estRows task access object operator info +Limit 1.00 root offset:0, count:1 +└─Selection 1.00 root json_overlaps(planner__core__casetest__physicalplantest__physical_plan.t.j, cast("[1, 2, 3]", json BINARY)) + └─IndexMerge 0.00 root type: union + ├─IndexRangeScan(Build) 0.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[1,1], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 0.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[2,2], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 0.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[3,3], keep order:false, stats:pseudo + └─TableRowIDScan(Probe) 0.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +Warning 1105 Scalar function 'json_overlaps'(signature: Unspecified, return type: bigint(20)) is not supported to push down to storage layer now. +explain format = 'brief' select /*+ use_index(t, kj) */ * from t where (1 member of (j) and a=1 ) limit 1; +id estRows task access object operator info +Limit 1.00 root offset:0, count:1 +└─IndexMerge 0.00 root type: union + ├─IndexRangeScan(Build) 1.25 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[1,1], keep order:false, stats:pseudo + └─Limit(Probe) 0.00 cop[tikv] offset:0, count:1 + └─Selection 0.00 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t.a, 1) + └─TableRowIDScan 1.25 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select /*+ use_index(t, kj) */ * from t where json_contains(j, '[1, 2, 3]') and a=1 limit 1; +id estRows task access object operator info +Limit 1.00 root offset:0, count:1 +└─IndexMerge 0.00 root type: intersection + ├─IndexRangeScan(Build) 1.25 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[1,1], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 1.25 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[2,2], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 1.25 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[3,3], keep order:false, stats:pseudo + └─Limit(Probe) 0.00 cop[tikv] offset:0, count:1 + └─Selection 0.00 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t.a, 1) + └─TableRowIDScan 1.25 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +explain format = 'brief' select /*+ use_index(t, kj) */ * from t where json_overlaps(j, '[1, 2, 3]') and a=1 limit 1; +id estRows task access object operator info +Limit 1.00 root offset:0, count:1 +└─Selection 1.00 root json_overlaps(planner__core__casetest__physicalplantest__physical_plan.t.j, cast("[1, 2, 3]", json BINARY)) + └─IndexMerge 1.00 root type: union + ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[1,1], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[2,2], keep order:false, stats:pseudo + ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:kj(cast(`j` as signed array)) range:[3,3], keep order:false, stats:pseudo + └─Selection(Probe) 1.00 cop[tikv] eq(planner__core__casetest__physicalplantest__physical_plan.t.a, 1) + └─TableRowIDScan 1.00 cop[tikv] table:t keep order:false, stats:pseudo +show warnings; +Level Code Message +Warning 1105 Scalar function 'json_overlaps'(signature: Unspecified, return type: bigint(20)) is not supported to push down to storage layer now. +set tidb_cost_model_version=DEFAULT; +explain select /*+ USE_INDEX_MERGE(t3, aid_c1, aid_c2) */ * from t3 where (aid = 1 and c1='aaa') or (aid = 1 and c2='bbb') limit 1; +id estRows task access object operator info +IndexMerge_20 1.00 root type: union, limit embedded(offset:0, count:1) +├─Limit_18(Build) 0.01 cop[tikv] offset:0, count:1 +│ └─IndexRangeScan_11 0.01 cop[tikv] table:t3, index:aid_c1(aid, c1) range:[1 "aaa",1 "aaa"], keep order:false, stats:pseudo +├─Limit_19(Build) 0.01 cop[tikv] offset:0, count:1 +│ └─IndexRangeScan_12 0.01 cop[tikv] table:t3, index:aid_c2(aid, c2) range:[1 "bbb",1 "bbb"], keep order:false, stats:pseudo +└─TableRowIDScan_13(Probe) 1.00 cop[tikv] table:t3 keep order:false, stats:pseudo +show warnings; +Level Code Message diff --git a/tests/integrationtest/r/planner/core/issuetest/planner_issue.result b/tests/integrationtest/r/planner/core/issuetest/planner_issue.result index 5d95672abacb7..9a5474ce1b188 100644 --- a/tests/integrationtest/r/planner/core/issuetest/planner_issue.result +++ b/tests/integrationtest/r/planner/core/issuetest/planner_issue.result @@ -180,3 +180,48 @@ LEFT JOIN tmp3 c3 ON c3.id = '1'; id id 1 1 1 1 +drop table if exists t1, t2; +create table t1(a varchar(20) collate utf8mb4_bin, index ia(a)); +insert into t1 value('测试'),('测试 '); +explain format = brief select *,length(a) from t1 where a like '测试 %'; +id estRows task access object operator info +Projection 250.00 root planner__core__issuetest__planner_issue.t1.a, length(planner__core__issuetest__planner_issue.t1.a)->Column#3 +└─UnionScan 250.00 root like(planner__core__issuetest__planner_issue.t1.a, "测试 %", 92) + └─IndexReader 250.00 root index:Selection + └─Selection 250.00 cop[tikv] like(planner__core__issuetest__planner_issue.t1.a, "测试 %", 92) + └─IndexRangeScan 250.00 cop[tikv] table:t1, index:ia(a) range:["测试 ","测试!"), keep order:false, stats:pseudo +explain format = brief select *,length(a) from t1 where a like '测试'; +id estRows task access object operator info +Projection 10.00 root planner__core__issuetest__planner_issue.t1.a, length(planner__core__issuetest__planner_issue.t1.a)->Column#3 +└─UnionScan 10.00 root like(planner__core__issuetest__planner_issue.t1.a, "测试", 92) + └─IndexReader 10.00 root index:Selection + └─Selection 10.00 cop[tikv] like(planner__core__issuetest__planner_issue.t1.a, "测试", 92) + └─IndexRangeScan 10.00 cop[tikv] table:t1, index:ia(a) range:["测试","测试"], keep order:false, stats:pseudo +select *,length(a) from t1 where a like '测试 %'; +a length(a) +测试 8 +select *,length(a) from t1 where a like '测试'; +a length(a) +测试 6 +create table t2(a varchar(20) collate gbk_chinese_ci, index ia(a)); +insert into t2 value('测试'),('测试 '); +explain format = brief select *,length(a) from t2 where a like '测试 %'; +id estRows task access object operator info +Projection 8000.00 root planner__core__issuetest__planner_issue.t2.a, length(to_binary(planner__core__issuetest__planner_issue.t2.a))->Column#3 +└─UnionScan 8000.00 root like(planner__core__issuetest__planner_issue.t2.a, "测试 %", 92) + └─TableReader 8000.00 root data:Selection + └─Selection 8000.00 cop[tikv] like(planner__core__issuetest__planner_issue.t2.a, "测试 %", 92) + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +explain format = brief select *,length(a) from t2 where a like '测试'; +id estRows task access object operator info +Projection 8000.00 root planner__core__issuetest__planner_issue.t2.a, length(to_binary(planner__core__issuetest__planner_issue.t2.a))->Column#3 +└─UnionScan 8000.00 root like(planner__core__issuetest__planner_issue.t2.a, "测试", 92) + └─TableReader 8000.00 root data:Selection + └─Selection 8000.00 cop[tikv] like(planner__core__issuetest__planner_issue.t2.a, "测试", 92) + └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo +select *,length(a) from t2 where a like '测试 %'; +a length(a) +测试 6 +select *,length(a) from t2 where a like '测试'; +a length(a) +测试 4 diff --git a/tests/integrationtest/r/planner/core/plan.result b/tests/integrationtest/r/planner/core/plan.result index 7a49cd0486ea4..b551124df076e 100644 --- a/tests/integrationtest/r/planner/core/plan.result +++ b/tests/integrationtest/r/planner/core/plan.result @@ -137,8 +137,9 @@ CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b @@ -147,8 +148,9 @@ Projection 33.33 root planner__core__plan.t1.b explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b @@ -157,8 +159,9 @@ Projection 33.33 root planner__core__plan.t1.b explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b @@ -167,8 +170,9 @@ Projection 33.33 root planner__core__plan.t1.b explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b @@ -177,8 +181,9 @@ Projection 33.33 root planner__core__plan.t1.b explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b @@ -187,8 +192,9 @@ Projection 33.33 root planner__core__plan.t1.b explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b @@ -197,8 +203,9 @@ Projection 33.33 root planner__core__plan.t1.b explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b @@ -207,8 +214,9 @@ Projection 33.33 root planner__core__plan.t1.b explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b @@ -217,8 +225,9 @@ Projection 33.33 root planner__core__plan.t1.b explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b @@ -227,8 +236,9 @@ Projection 33.33 root planner__core__plan.t1.b explain format='brief' select * from t1 where concat(a, b) like "aadwa" and a = "a"; id estRows task access object operator info Projection 0.10 root planner__core__plan.t1.a, planner__core__plan.t1.b -└─IndexReader 0.10 root index:IndexRangeScan - └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo +└─IndexReader 0.10 root index:Selection + └─Selection 0.10 cop[tikv] like(concat(planner__core__plan.t1.a, planner__core__plan.t1.b), "aadwa", 92) + └─IndexRangeScan 0.10 cop[tikv] table:t1, index:idx2(a, concat(`a`, `b`), b) range:["a" "aadwa","a" "aadwa"], keep order:false, stats:pseudo explain format='brief' select b from t1 where concat(a, b) >= "aa" and a = "b"; id estRows task access object operator info Projection 33.33 root planner__core__plan.t1.b diff --git a/tests/integrationtest/t/planner/core/issuetest/planner_issue.test b/tests/integrationtest/t/planner/core/issuetest/planner_issue.test index 1b58c7c5046c7..372e9eb8a67a6 100644 --- a/tests/integrationtest/t/planner/core/issuetest/planner_issue.test +++ b/tests/integrationtest/t/planner/core/issuetest/planner_issue.test @@ -136,3 +136,18 @@ FROM t2 db LEFT JOIN tmp3 c2 ON c2.id = '1' LEFT JOIN tmp3 c3 ON c3.id = '1'; + +# https://github.com/pingcap/tidb/issues/48821 +drop table if exists t1, t2; +create table t1(a varchar(20) collate utf8mb4_bin, index ia(a)); +insert into t1 value('测试'),('测试 '); +explain format = brief select *,length(a) from t1 where a like '测试 %'; +explain format = brief select *,length(a) from t1 where a like '测试'; +select *,length(a) from t1 where a like '测试 %'; +select *,length(a) from t1 where a like '测试'; +create table t2(a varchar(20) collate gbk_chinese_ci, index ia(a)); +insert into t2 value('测试'),('测试 '); +explain format = brief select *,length(a) from t2 where a like '测试 %'; +explain format = brief select *,length(a) from t2 where a like '测试'; +select *,length(a) from t2 where a like '测试 %'; +select *,length(a) from t2 where a like '测试';