You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Though users don't deliberately write redundant expressions in the SQL, there are still redundant expressions, such as those from generated SQLs.
In our current implementation, we have RemoveDupExprs() and PropagateConstant() for AND lists. However, the correspondence for the OR list is lacking. So, there could be redundant filters in the OR list in the final plan, which can sometimes cause an inefficient plan.
For example:
createtablet(a int, b int, c int, index ia(a), index ib(b), index ic(c));
explain select*from t where a =1or a =1or b =2or b =2or c =3or c =3;
> explain select * from t where a = 1 or a = 1 or b = 2 or b = 2 or c = 3 or c = 3;
+--------------------------------+---------+-----------+----------------------+---------------------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------------+---------+-----------+----------------------+---------------------------------------------+
| IndexMerge_15 | 29.97 | root | | type: union |
| ├─IndexRangeScan_8(Build) | 10.00 | cop[tikv] | table:t, index:ia(a) | range:[1,1], keep order:false, stats:pseudo |
| ├─IndexRangeScan_9(Build) | 10.00 | cop[tikv] | table:t, index:ia(a) | range:[1,1], keep order:false, stats:pseudo |
| ├─IndexRangeScan_10(Build) | 10.00 | cop[tikv] | table:t, index:ib(b) | range:[2,2], keep order:false, stats:pseudo |
| ├─IndexRangeScan_11(Build) | 10.00 | cop[tikv] | table:t, index:ib(b) | range:[2,2], keep order:false, stats:pseudo |
| ├─IndexRangeScan_12(Build) | 10.00 | cop[tikv] | table:t, index:ic(c) | range:[3,3], keep order:false, stats:pseudo |
| ├─IndexRangeScan_13(Build) | 10.00 | cop[tikv] | table:t, index:ic(c) | range:[3,3], keep order:false, stats:pseudo |
| └─TableRowIDScan_14(Probe) | 29.97 | cop[tikv] | table:t | keep order:false, stats:pseudo |
+--------------------------------+---------+-----------+----------------------+---------------------------------------------+
The text was updated successfully, but these errors were encountered:
Enhancement
Though users don't deliberately write redundant expressions in the SQL, there are still redundant expressions, such as those from generated SQLs.
In our current implementation, we have
RemoveDupExprs()
andPropagateConstant()
for AND lists. However, the correspondence for the OR list is lacking. So, there could be redundant filters in the OR list in the final plan, which can sometimes cause an inefficient plan.For example:
The text was updated successfully, but these errors were encountered: