Skip to content

Commit

Permalink
plan: propagate constant over outer join (#7794)
Browse files Browse the repository at this point in the history
- extract `outerCol = const` from join conditions and filter conditions,
  substitute `outerCol` in join conditions with `const`;
- extract `outerCol = innerCol` from join conditions, derive new join
  conditions based on this column equal condition and `outerCol` related
  expressions in join conditions and filter conditions;
  • Loading branch information
eurekaka authored Oct 16, 2018
1 parent 19e4e2f commit 6064d64
Show file tree
Hide file tree
Showing 5 changed files with 670 additions and 127 deletions.
6 changes: 3 additions & 3 deletions executor/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,11 @@ func (s *testSuite) TestMergejoinOrder(c *C) {
tk.MustExec("insert into t2 select a*100, b*100 from t1;")

tk.MustQuery("explain select /*+ TIDB_SMJ(t2) */ * from t1 left outer join t2 on t1.a=t2.a and t1.a!=3 order by t1.a;").Check(testkit.Rows(
"MergeJoin_15 12500.00 root left outer join, left key:test.t1.a, right key:test.t2.a, left cond:[ne(test.t1.a, 3)]",
"MergeJoin_15 10000.00 root left outer join, left key:test.t1.a, right key:test.t2.a, left cond:[ne(test.t1.a, 3)]",
"├─TableReader_11 10000.00 root data:TableScan_10",
"│ └─TableScan_10 10000.00 cop table:t1, range:[-inf,+inf], keep order:true, stats:pseudo",
"└─TableReader_13 10000.00 root data:TableScan_12",
" └─TableScan_12 10000.00 cop table:t2, range:[-inf,+inf], keep order:true, stats:pseudo",
"└─TableReader_13 6666.67 root data:TableScan_12",
" └─TableScan_12 6666.67 cop table:t2, range:[-inf,3), (3,+inf], keep order:true, stats:pseudo",
))

tk.MustExec("set @@tidb_max_chunk_size=1")
Expand Down
Loading

0 comments on commit 6064d64

Please sign in to comment.