Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-10568

Select count(distinct()) can have more optimal execution plan

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.10.0, 0.11.0, 0.12.0, 0.13.0, 0.14.0, 1.0.0, 1.1.0
    • Fix Version/s: 1.2.0
    • Component/s: CBO, Logical Optimizer
    • Labels:
      None

      Description

      select count(distinct ss_ticket_number) from store_sales;
      

      can be rewritten as

      select count(1) from (select distinct ss_ticket_number from store_sales) a;
      

      which may run upto 3x faster

        Attachments

        1. HIVE-10568.1.patch
          36 kB
          Ashutosh Chauhan
        2. HIVE-10568.2.patch
          37 kB
          Ashutosh Chauhan
        3. HIVE-10568.patch
          23 kB
          Ashutosh Chauhan
        4. HIVE-10568.patch
          23 kB
          Ashutosh Chauhan

          Issue Links

            Activity

              People

              • Assignee:
                ashutoshc Ashutosh Chauhan
                Reporter:
                mmokhtar Mostafa Mokhtar
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: