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

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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 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
    • 1.2.0
    • CBO, Logical Optimizer
    • 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.2.patch
          37 kB
          Ashutosh Chauhan
        2. HIVE-10568.1.patch
          36 kB
          Ashutosh Chauhan
        3. HIVE-10568.patch
          23 kB
          Ashutosh Chauhan
        4. HIVE-10568.patch
          23 kB
          Ashutosh Chauhan

        Issue Links

          Activity

            People

              ashutoshc Ashutosh Chauhan
              mmokhtar Mostafa Mokhtar
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: