Uploaded image for project: 'Tajo (Retired)'
  1. Tajo (Retired)
  2. TAJO-601

Improve distinct aggregation query processing

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.8.0
    • Planner/Optimizer
    • None

    Description

      Currently, distinct aggregation queries are executed as follows:

      • the first stage: it just shuffles tuples by hashing grouping keys.
      • the second stage: it sorts them and executes sort aggregation.

      This way executes queries including distinct aggregation functions with only two stages. But, it leads to large intermediate data during shuffle phase.

      This kind of query can be rewritten as two queries:

      original query
      SELECT grp1, grp2, count(*) as total, count(distinct grp3) as distinct_col from rel1 group by grp1, grp2;
      
      rewritten query
      SELECT grp1, grp2, sum(cnt) as total, count(grp3) as distinct_col from (
        SELECT grp1, grp2, grp3, count(*) as cnt from rel1 group by grp1, grp2, grp3) tmp1 group by grp1, grp2
      ) table1;
      

      I'm expecting that this rewrite will significantly reduce the intermediate data volume and query response time in most cases.

      Attachments

        1. TAJO-601_140220_142800.patch
          83 kB
          Hyunsik Choi
        2. TAJO-601.patch
          83 kB
          Hyunsik Choi

        Issue Links

          Activity

            People

              hyunsik Hyunsik Choi
              hyunsik Hyunsik Choi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: