Closed
Description
Search before asking
- I had searched in the issues and found no similar issues.
Description
Problem:
select * from t where k=1 union all select * from t where k=3;
should convert to:
select * from t where k=1 or k=3;
to reduce scanners
Reproduce Steps:
1、create table:
CREATE TABLE `t` (
`k` int NULL,
`v` int NULL
) ENGINE=OLAP
DUPLICATE KEY(`k`)
DISTRIBUTED BY HASH(`k`) BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 1");
2、add data:
insert into t values(1,2),(3,4);
3、explain union all SQL
> explain shape plan select * from t where k=1 union all select * from t where k=3;
+--------------------------------------------------------+
| Explain String(Nereids Planner) |
+--------------------------------------------------------+
| PhysicalResultSink |
| --PhysicalDistribute[DistributionSpecGather] |
| ----PhysicalUnion |
| ------PhysicalDistribute[DistributionSpecExecutionAny] |
| --------filter((t.k = 1)) |
| ----------PhysicalOlapScan[t] |
| ------PhysicalDistribute[DistributionSpecExecutionAny] |
| --------filter((t.k = 3)) |
| ----------PhysicalOlapScan[t] |
+--------------------------------------------------------+
4、explain equal SQL:
> explain shape plan select * from t where k=1 or k=3;
+----------------------------------------------+
| Explain String(Nereids Planner) |
+----------------------------------------------+
| PhysicalResultSink |
| --PhysicalDistribute[DistributionSpecGather] |
| ----filter(k IN (1, 3)) |
| ------PhysicalOlapScan[t] |
+----------------------------------------------+
Solution
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
No labels