Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-21580

Sql. Unable to optimise query using only two phase aggregates

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0
    • sql

    Description

      As for now, query planner returns following plan for q1 from TPC H suite:

      IgniteColocatedSortAggregate
        IgniteExchange(distribution=[single])
          IgniteSort
            IgniteIndexScan(index=[L_SD], searchBounds=[[RangeBounds [lowerBound=null, upperBound=-(1998-12-01, 7776000000:INTERVAL DAY), lowerInclude=true, upperInclude=true]]])
      

      The first problem is it's not even optimal variant from possible ones. By simply excluding SortAggregateConverterRule.COLOCATED from planning phase, we will get plan as follow:

      IgniteSort
        IgniteColocatedHashAggregate
          IgniteExchange(distribution=[single])
            IgniteIndexScan(index=[L_SD], searchBounds=[[RangeBounds [lowerBound=null, upperBound=-(1998-12-01, 7776000000:INTERVAL DAY), lowerInclude=true, upperInclude=true]]])
      

      Latter plan is executed ~40% faster than the first one.

      Seems, it's possible to reduce time even further by taking an advantage of two-phase aggregates, but disabling both version of colocated aggregates results in an exception during planning phase.

      Within this ticket, let's address the issue preventing optimiser from usage of two-phase aggregates, and also tweak cost function to make optimiser choose better plan.

      Attachments

        Issue Links

          Activity

            People

              amashenkov Andrey Mashenkov
              korlov Konstantin Orlov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h