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

[N1QL] correct index is not being selected

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 5.5.6, 6.0.3, 6.5.0
    • 6.5.0
    • query
    • 6.5.0-3573,5.5.5-4521
    • Untriaged
    • Yes

    Description

      Logs:

      https://s3.amazonaws.com/bugdb/jira/coveringissue/collectinfo-2019-06-26T182746-ns_1%40cb.local.zip

      I have two indexes in my system:

      CREATE INDEX `coveringindexwithwhere0` ON `default`(`email`,`VMs`) WHERE (10 < `join_day`)

      CREATE INDEX `shortcoveringindex0` ON `default`(`email`) WHERE (10 < `join_day`)

      I run this query:

      explain select email from default where email LIKE '%@%.%' and join_day > 10

      The wrong index is being picked up for this query, before (in 6.5.0-3511) shortcoveringindex0 would be the index picked up for this query, now it is picking up coveringindexwithwhere0.

      Found this issue in a weekly regression run, can provide the rest of the test details if required

      Here is the explain plan:

      [
        {
          "plan": {
            "#operator": "Sequence",
            "~children": [
              {
                "#operator": "IndexScan3",
                "covers": [
                  "cover ((`default`.`email`))",
                  "cover ((`default`.`VMs`))",
                  "cover ((meta(`default`).`id`))"
                ],
                "filter_covers": {
                  "cover ((10 < (`default`.`join_day`)))": true
                },
                "index": "coveringindexwithwhere0",
                "index_id": "87e6f44c62d85cfc",
                "index_projection": {
                  "entry_keys": [
                    0
                  ]
                },
                "keyspace": "default",
                "namespace": "default",
                "spans": [
                  {
                    "range": [
                      {
                        "high": "[]",
                        "inclusion": 1,
                        "low": "\"\""
                      }
                    ]
                  }
                ],
                "using": "gsi"
              },
              {
                "#operator": "Parallel",
                "~child": {
                  "#operator": "Sequence",
                  "~children": [
                    {
                      "#operator": "Filter",
                      "condition": "((cover ((`default`.`email`)) like \"%@%.%\") and cover ((10 < (`default`.`join_day`))))"
                    },
                    {
                      "#operator": "InitialProject",
                      "result_terms": [
                        {
                          "expr": "cover ((`default`.`email`))"
                        }
                      ]
                    },
                    {
                      "#operator": "FinalProject"
                    }
                  ]
                }
              }
            ]
          },
          "text": "select email from default where email LIKE '%@%.%' and join_day > 10"
        }
      ]
      

      Attachments

        Issue Links

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

          Activity

            People

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