liutang123 opened a new issue #4481:
URL: https://github.com/apache/incubator-doris/issues/4481


   issue Reason
   --
   Now, Doris will create two fragments for aggretion.
   Sometime, **Exchange for aggregation is unnecessary.**
   Think about follow cases:
   1. aggregate an unpartitioned table.
   a. create table SQL:
   ```
   CREATE TABLE `llj_test_1` (
     `dt` int(11) NOT NULL COMMENT "",
     `dis_key` varchar(20) NOT NULL COMMENT ""
   ) ENGINE=OLAP
   DUPLICATE KEY(`dt`, `dis_key`)
   COMMENT "OLAP"
   DISTRIBUTED BY HASH(`dt`, `dis_key`) BUCKETS 3
   PROPERTIES (
   "replication_num" = "3",
   "in_memory" = "false",
   "storage_format" = "DEFAULT"
   );
   ```
   b. query SQL:`select dt, dis_key,count(1) from  llj_test_1  group by dt, 
dis_key;`
   
   2. aggregate a partitioned table:
   a. create table SQL:
   ```
   CREATE TABLE `llj_test` (
     `dt` int(11) NOT NULL COMMENT "",
     `dis_key` varchar(20) NOT NULL COMMENT ""
   ) ENGINE=OLAP
   DUPLICATE KEY(`dt`, `dis_key`)
   COMMENT "OLAP"
   PARTITION BY RANGE(`dt`)
   (PARTITION p20180822 VALUES [("19000101"), ("20181021")),
   PARTITION p20181207 VALUES [("20181021"), ("20181022")))
   DISTRIBUTED BY HASH(`dt`, `dis_key`) BUCKETS 3
   PROPERTIES (
   "replication_num" = "1",
   "in_memory" = "false",
   "storage_format" = "DEFAULT"
   );
   ```
   b. query SQL:`select dt, dis_key,count(1) from  llj_test  group by dt, 
dis_key;`
   
   Suggestion
   --
   In `DistributedPlanner`, do not add the unnecessary `Exchange`s.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to