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

Adaptive Index with UNNEST alias returns wrong results

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Unknown

    Description

      insert into default values ("k001",{"f1":3,"a1":[{"b":2}]});
      create index ix10 on default (DISTINCT PAIRS(self));
      SELECT 1 FROM default AS d  UNNEST d.a1 AS c WHERE d.f1 = 3;
      
      

      Above query gives results some time and no result some time.
      If you remove AS c it gives results.

      EXPLAIN SELECT 1 FROM default AS d  UNNEST d.a1 AS c WHERE d.f1 = 3;
      {
          "requestID": "f4ef34ac-0669-42c9-adb5-2716a0015893",
          "signature": "json",
          "results": [
          {
              "plan": {
                  "#operator": "Sequence",
                  "~children": [
                      {
                          "#operator": "IntersectScan",
                          "scans": [
                              {
                                  "#operator": "DistinctScan",
                                  "scan": {
                                      "#operator": "IndexScan3",
                                      "as": "d",
                                      "index": "ix10",
                                      "index_id": "119c5e84caf444d6",
                                      "index_projection": {
                                          "primary_key": true
                                      },
                                      "keyspace": "default",
                                      "namespace": "default",
                                      "spans": [
                                          {
                                              "exact": true,
                                              "range": [
                                                  {
                                                      "high": "[\"f1\", 3]",
                                                      "inclusion": 3,
                                                      "low": "[\"f1\", 3]"
                                                  }
                                              ]
                                          }
                                      ],
                                      "using": "gsi"
                                  }
                              },
                              {
                                  "#operator": "DistinctScan",
                                  "scan": {
                                      "#operator": "IndexScan3",
                                      "as": "d",
                                      "index": "ix10",
                                      "index_id": "119c5e84caf444d6",
                                      "index_projection": {
                                          "primary_key": true
                                      },
                                      "keyspace": "default",
                                      "namespace": "default",
                                      "spans": [
                                          {
                                              "exact": true,
                                              "range": [
                                                  {
                                                      "high": "[successor(\"a1\")]",
                                                      "inclusion": 1,
                                                      "low": "[\"a1\", []]"
                                                  }
                                              ]
                                          }
                                      ],
                                      "using": "gsi"
                                  }
                              },
                              {
                                  "#operator": "DistinctScan",
                                  "scan": {
                                      "#operator": "IndexScan3",
                                      "as": "d",
                                      "index": "ix10",
                                      "index_id": "119c5e84caf444d6",
                                      "index_projection": {
                                          "primary_key": true
                                      },
                                      "keyspace": "default",
                                      "namespace": "default",
                                      "spans": [
                                          {
                                              "exact": true,
                                              "range": [
                                                  {
                                                      "high": "[\"a1\", {}]",
                                                      "inclusion": 1,
                                                      "low": "[\"a1\", false]"
                                                  }
                                              ]
                                          }
                                      ],
                                      "using": "gsi"
                                  }
                              },
                              {
                                  "#operator": "DistinctScan",
                                  "scan": {
                                      "#operator": "IndexScan3",
                                      "as": "d",
                                      "index": "ix10",
                                      "index_id": "119c5e84caf444d6",
                                      "index_projection": {
                                          "primary_key": true
                                      },
                                      "keyspace": "default",
                                      "namespace": "default",
                                      "spans": [
                                          {
                                              "exact": true,
                                              "range": [
                                                  {
                                                      "high": "[successor(\"c\")]",
                                                      "inclusion": 0,
                                                      "low": "[\"c\"]"
                                                  }
                                              ]
                                          }
                                      ],
                                      "using": "gsi"
                                  }
                              }
                          ]
                      },
                      {
                          "#operator": "Fetch",
                          "as": "d",
                          "keyspace": "default",
                          "namespace": "default"
                      },
                      {
                          "#operator": "Parallel",
                          "~child": {
                              "#operator": "Sequence",
                              "~children": [
                                  {
                                      "#operator": "Filter",
                                      "condition": "(((`d`.`f1`) = 3) and is_array((`d`.`a1`)))"
                                  },
                                  {
                                      "#operator": "Unnest",
                                      "as": "c",
                                      "expr": "(`d`.`a1`)",
                                      "filter": "(`c` is not missing)"
                                  }
                              ]
                          }
                      },
                      {
                          "#operator": "Parallel",
                          "~child": {
                              "#operator": "Sequence",
                              "~children": [
                                  {
                                      "#operator": "InitialProject",
                                      "result_terms": [
                                          {
                                              "expr": "1"
                                          }
                                      ]
                                  }
                              ]
                          }
                      }
                  ]
              },
              "text": "SELECT 1 FROM default AS d  UNNEST d.a1 AS c WHERE d.f1 = 3;"
          }
          ],
          "status": "success",
          "metrics": {
              "elapsedTime": "2.398544ms",
              "executionTime": "2.284296ms",
              "resultCount": 1,
              "resultSize": 7039,
              "serviceLoad": 2
          }
      }
      

      IntersectScan 4 should not be present.

      "spans": [
                                          {
                                              "exact": true,
                                              "range": [
                                                  {
                                                      "high": "[successor(\"c\")]",
                                                      "inclusion": 0,
                                                      "low": "[\"c\"]"
                                                  }
                                              ]
                                          }
                                      ],
      

      Attachments

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

        Activity

          People

            ajay.bhullar Ajay Bhullar
            Sitaram.Vemulapalli Sitaram Vemulapalli
            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