tidb
tidb copied to clipboard
convert join to table dual for false result of constant propagation
Feature Request
Is your feature request related to a problem? Please describe:
create table t1(id int primary key, a int);
create table t2(id int primary key, a int);
mysql> explain select * from t1 join t2 on t1.a = t2.a where t2.a = null;
+-----------------------+-------------+------+-------------------------------------------------------------+
| id | count | task | operator info |
+-----------------------+-------------+------+-------------------------------------------------------------+
| HashLeftJoin_7 | 80000000.00 | root | inner join, inner:TableDual_11 |
| ├─TableReader_10 | 10000.00 | root | data:TableScan_9 |
| │ └─TableScan_9 | 10000.00 | cop | table:t1, range:[-inf,+inf], keep order:false, stats:pseudo |
| └─TableDual_11 | 8000.00 | root | rows:0 |
+-----------------------+-------------+------+-------------------------------------------------------------+
4 rows in set (0.00 sec)
First, count field should be wrong.
Second, the join should be a table dual.
Describe the feature you'd like:
Check the result of PropagateConstant, if it is always false, convert the plan node to table dual.
Describe alternatives you've considered:
None
Teachability, Documentation, Adoption, Migration Strategy:
None