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

Static Spans are modified result in wrong plan

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 7.1.0
    • 6.6.3, 7.0.2, 7.1.0
    • query
    • None
    • Untriaged
    • 1
    • 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

          People

            kamini.jagtiani Kamini Jagtiani
            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