Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-27861

Optimize MIN aggregate without group by

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.5.0
    • 5.5.0
    • secondary-index
    • Triaged
    • Unknown

    Description

      For MIN aggregate without group by, N1QL sends Limit 1 queries in API2 e.g. if the aggregate is on the first column or aggregate on second column but first column has equality.

      With API3, this optimization is no longer available.

      Either:
      1. Indexer can have the extra logic to determine when such optimizations can be applied
      2. N1QL can call API2 in such cases with LIMIT 1 or API3 without pushing down group aggr.

      Attachments

        For Gerrit Dashboard: MB-27861
        # Subject Branch Project Status CR V

        Activity

          Deepkaran Salooja does this need QE verification? if so, can you please provide some steps?

          arunkumar Arunkumar Senthilnathan added a comment - Deepkaran Salooja does this need QE verification? if so, can you please provide some steps?

          This was a small perf optimization. No functional verification needed. Dev has already verified the perf.

          deepkaran.salooja Deepkaran Salooja added a comment - This was a small perf optimization. No functional verification needed. Dev has already verified the perf.

          Rules were simplified due to MB-29553 with commit af8b9cd76f7561ac30a6272eef7e91ac240291f4

          prathibha Prathibha Bisarahalli (Inactive) added a comment - Rules were simplified due to MB-29553 with commit af8b9cd76f7561ac30a6272eef7e91ac240291f4

          Sitaram Vemulapalli I need a clarification about below rules:

          GROUP BY is NIL (length of 0)
          Number of aggregates are 1
          KeyPos 0 (leading or first non equality)
          ASC Index on Pos 0 MIN return first non-missing,non-null value is encountered scan can be stopped , if none return NULL
          KeyPos 0 (leading or first non equality)
          upto keyPos all leading keys all spans(across) must have have same lows and high , inclusive 3
          Desc Index On Pos 0 MAX return first non-missing,non-null value is encountered scan can be stopped, if none return NULL
          COUNT (DISTINCT <constant>)
          After one item is scanned scan can be stopped
          

          if MIN Aggr is on KeyPos > 0 , for example, KeyPos = 3 and first three positions are: ASC, DESC< ASC, then do the rules still apply given that scan is equality low=high, incl 3 for first three positions (0, 1, 2) ?

          prathibha Prathibha Bisarahalli (Inactive) added a comment - Sitaram Vemulapalli I need a clarification about below rules: GROUP BY is NIL (length of 0) Number of aggregates are 1 KeyPos 0 (leading or first non equality) ASC Index on Pos 0 MIN return first non-missing,non-null value is encountered scan can be stopped , if none return NULL KeyPos 0 (leading or first non equality) upto keyPos all leading keys all spans(across) must have have same lows and high , inclusive 3 Desc Index On Pos 0 MAX return first non-missing,non-null value is encountered scan can be stopped, if none return NULL COUNT (DISTINCT <constant>) After one item is scanned scan can be stopped if MIN Aggr is on KeyPos > 0 , for example, KeyPos = 3 and first three positions are: ASC, DESC< ASC, then do the rules still apply given that scan is equality low=high, incl 3 for first three positions (0, 1, 2) ?

          if MIN Aggr is on KeyPos > 0 , for example, KeyPos = 3 and first three positions are: ASC, DESC< ASC, then do the rules still apply given that scan is equality low=high, incl 3 for first three positions (0, 1, 2) ?
          keyPos=3 and first there is equal (first there asc,desc,asc doesn't matter because of equal) but 4th asc/desc matters. asc first, desc last value

          Sitaram.Vemulapalli Sitaram Vemulapalli added a comment - if MIN Aggr is on KeyPos > 0 , for example, KeyPos = 3 and first three positions are: ASC, DESC< ASC, then do the rules still apply given that scan is equality low=high, incl 3 for first three positions (0, 1, 2) ? keyPos=3 and first there is equal (first there asc,desc,asc doesn't matter because of equal) but 4th asc/desc matters. asc first, desc last value

          People

            korrigan.clark Korrigan Clark (Inactive)
            deepkaran.salooja Deepkaran Salooja
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty