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

N1QL Advisor: does not provide enough set of required indexes for DELETE query

    XMLWordPrintable

Details

    • Untriaged
    • Centos 64-bit
    • Unknown

    Description

      Build: 6.5.0 build 4282.

      Standard `travel-sample` bucket.

      No primary/secondary indexes for this bucket.

      I'm trying to run the following query:

       

      DELETE FROM `travel-sample` WHERE ((free_breakfast=true OR city is null)) OR (id <= "549");
      

      The answer is totally predictable:

       

      [
       {
       "code": 4000,
       "msg": "No index available on keyspace travel-sample that matches your query. Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online.",
       "query": "DELETE FROM `travel-sample` WHERE ((free_breakfast=true OR city is null)) OR (id <= \"549\");"
       }
      ]

       

       

      Running this:

      advise DELETE FROM `travel-sample` WHERE ((free_breakfast=true OR city is null)) OR (id <= "549");
      
      

      got this:

       

      Index Recommendations
      CREATE INDEX adv_free_breakfast ON `travel-sample`(`free_breakfast`)
      CREATE INDEX adv_id ON `travel-sample`(`id`)
      

      After executing those recommendations, I got 2 indexes:

       

      CREATE INDEX `adv_free_breakfast` ON `travel-sample`(`free_breakfast`)
      CREATE INDEX `adv_id` ON `travel-sample`(`id`)
      

      Trying to run DELETE once again:

      [
       {
       "code": 4000,
       "msg": "No index available on keyspace travel-sample that matches your query. Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online.",
       "query": "DELETE FROM `travel-sample` WHERE ((free_breakfast=true OR city is null)) OR (id <= \"549\");"
       }
      ]

      Advise gives me this:

       

      Index Recommendations
      CREATE INDEX adv_free_breakfast ON `travel-sample`(`free_breakfast`)
      CREATE INDEX adv_id ON `travel-sample`(`id`)
      

      But, I already have those 2 indexes.

      If I will change DELETE query a little bit (I've changed `city` field condition):

       

      DELETE FROM `travel-sample` WHERE ((free_breakfast=true OR city ="AAA")) OR (id <= "549");

      I will be provided with correct set of recommended indexes:

       

      Index Recommendations
      CREATE INDEX adv_free_breakfast ON `travel-sample`(`free_breakfast`)
      CREATE INDEX adv_city ON `travel-sample`(`city`)
      CREATE INDEX adv_id ON `travel-sample`(`id`)
      

       
       
       
       
       

      Attachments

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

        Activity

          People

            ajay.bhullar Ajay Bhullar
            evgeny.makarenko Evgeny Makarenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty