Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-6836

Eliminate StreamingAggr for COUNT DISTINCT

    XMLWordPrintableJSON

Details

    Description

      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.

      Attachments

        Activity

          People

            ben-zvi Boaz Ben-Zvi
            ben-zvi Boaz Ben-Zvi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: