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

Static Spans are modified result in wrong plan

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.6.3, Neo, 7.0.2
    • Fix Version/s: Neo
    • Component/s: query
    • Labels:
      None
    • Triage:
      Untriaged
    • Story Points:
      1
    • Is this a Regression?:
      Unknown

      Description

      Repro:

      create index ix1 on default (DISTINCT ARRAY v.id FOR v IN arr1 END);
      create index ix2 on default (c1);
      EXPLAIN SELECT  d.c1 FROM default AS d WHERE d.c1 IS NOT NULL GROUP BY d.c1;
      

      Above one uses index aggregates.
      Run the following statement (there extra predicate v.x so the span will not exact)

      EXPLAIN SELECT 1 FROM default AS d WHERE ANY v IN d.arr1 SATISFIES v.id IS NOT NULL AND v.x = 10 END;
      

      Now Rerun. It no longer uses index aggregates. Only option is restart query service.

      EXPLAIN SELECT  d.c1 FROM default AS d WHERE d.c1 IS NOT NULL GROUP BY d.c1;
      

      Reason:
      There v.id IS NOT NULL , v.id is array index key. It generates _EXACT_VALUED_SPANS (Static span) Later it sets false (https://github.com/couchbase/query/blob/master/planner/sarg_any.go#L116) without making copy. Also at it modifies others https://github.com/couchbase/query/blob/master/planner/sarg_any.go#L87-L97

      This can happen any other static spans.

      Possible fix is at https://github.com/couchbase/query/blob/master/planner/sarg_any.go#L86
      sp = sp.Copy()

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

          Hide
          Sitaram.Vemulapalli Sitaram Vemulapalli added a comment - - edited

          FYI: This is fixed in Neo as part of MB-32506

          Show
          Sitaram.Vemulapalli Sitaram Vemulapalli added a comment - - edited FYI: This is fixed in Neo as part of MB-32506

            People

            Assignee:
            kamini.jagtiani Kamini Jagtiani
            Reporter:
            Sitaram.Vemulapalli Sitaram Vemulapalli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes

                  PagerDuty