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

Advise : Incorrect index recommendation for query with same field in predicate multiple times

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Unknown

    Description

      Build : 7.0.0-2073 & 6.6.0-7637

      [
        {
          "#operator": "Advise",
          "advice": {
            "#operator": "IndexAdvice",
            "adviseinfo": {
              "current_indexes": [
                {
                  "index_statement": "CREATE INDEX def_type ON `travel-sample`(`type`)",
                  "keyspace_alias": "travel-sample"
                },
                {
                  "index_statement": "CREATE INDEX def_city ON `travel-sample`(`city`)",
                  "keyspace_alias": "travel-sample"
                }
              ],
              "recommended_indexes": {
                "covering_indexes": [
                  {
                    "index_statement": "CREATE INDEX adv_upper_type_lower_type_city_type ON `travel-sample`(upper((`type`)),lower((`type`)),`city`,`type`)",
                    "keyspace_alias": "travel-sample"
                  }
                ],
                "indexes": [
                  {
                    "index_statement": "CREATE INDEX adv_upper_type_lower_type_city ON `travel-sample`(`city`,lower((`type`)),upper((`type`)))",
                    "keyspace_alias": "travel-sample",
                    "recommending_rule": "Index keys follow order of predicate types: 1. Common leading key for disjunction (5. less than/greater than, 5. less than/greater than, 7. not null/not missing/valued)."
                  }
                ]
              }
            }
          },
          "query": "SELECT `type`,`city`,count(*) FROM `travel-sample`  where city is not null and lower(`type`) != \"airport\" and upper(`type`)!=\"landmark\" GROUP BY `type`,city t order by `type`,city LIMIT 100 OFFSET 500"
        }
      ]
      

      The advise can be optimized to have just city and type fields in the index, instead of having the type field indexed multiple times.

      Attachments

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

        Activity

          People

            chang.liu Chang Liu (Inactive)
            mihir.kamdar Mihir Kamdar (Inactive)
            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