Boaz Ben-Zvi created DRILL-6836: ----------------------------------- Summary: Eliminate StreamingAggr for COUNT DISTINCT Key: DRILL-6836 URL: https://issues.apache.org/jira/browse/DRILL-6836 Project: Apache Drill Issue Type: Improvement Components: Execution - Relational Operators, Query Planning & Optimization Affects Versions: 1.14.0 Reporter: Boaz Ben-Zvi Assignee: Boaz Ben-Zvi Fix For: 1.16.0
The COUNT DISTINCT operation is often implemented with a Hash-Aggr operator for the DISTINCT, and a Streaming-Aggr above to perform the COUNT. That Streaming-Aggr does the counting like any aggregation, counting each value, batch after batch. While very efficient, that counting work is basically not needed, as the Hash-Aggr knows the number of distinct values (in the in-memory partitions). Hence _a possible small performance improvement_ - eliminate the Streaming-Aggr operator, and notify the Hash-Aggr to return a COUNT (these are Planner changes). The Hash-Aggr operator would need to generate the single Float8 column output schema, and output that batch with a single value, just like the Streaming -Aggr did (likely without generating code). In case of a spill, the Hash-Aggr still needs to read and process those partitions, to get the exact distinct number. The expected improvement is the elimination of the batch by batch output from the Hash-Aggr, and the batch by batch, row by row processing of the Streaming-Aggr. -- This message was sent by Atlassian JIRA (v7.6.3#76005)