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

[CBSE] partition Index order is not honored when index projection include all keys + document key

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 7.0.0
    • 6.6.0, Cheshire-Cat
    • secondary-index
    • None
    • Untriaged
    • 1
    • Unknown

    Description

      May be present from 5.5

      Repro:
      2 indexer nodes.

      INSERT INTO default VALUES("f01", {"score":8.1});
      INSERT INTO default VALUES("f02", {"score":8.2});
      INSERT INTO default VALUES("f03", {"score":8.3});
      INSERT INTO default VALUES("f04", {"score":9.3});
      DROP INDEX default.ix11;
      CREATE INDEX `ix11` ON `default`(score DESC,c) PARTITION BY hash((meta().`id`));
      select META(d).id, score, c FROM default AS d where d.score > 8 ORDER BY d.score desc;
      

       
                      {
                          "#operator": "Sequence",
                          "~children": [
                              {
                                  "#operator": "IndexScan3",
                                  "as": "d",
                                  "covers": [
                                      "cover ((`d`.`score`))",
                                      "cover ((`d`.`c`))",
                                      "cover ((meta(`d`).`id`))"
                                  ],
                                  "filter": "(8 < cover ((`d`.`score`)))",
                                  "index": "ix11",
                                  "index_id": "32af084a887521ec",
                                  "index_order": [
                                      {
                                          "desc": true,
                                          "keypos": 0
                                      }
                                  ],
                                  "keyspace": "default",
                                  "namespace": "default",
                                  "spans": [
                                      {
                                          "exact": true,
                                          "range": [
                                              {
                                                  "inclusion": 0,
                                                  "low": "8"
                                              }
                                          ]
                                      }
                                  ],
                                  "using": "gsi"
                              }
      

      index_order keypos 0 desc is not honored.

      The repro has special situations. All the index keys and document key are required so index_projection is omitted (indexer project everything).

      If we remove projection c or meta().id , query adds index_projection and it honors index order.

       
                                  "index_projection": {
                                      "entry_keys": [
                                          0
                                      ],
                                      "primary_key": true
                                  }
       
       
      
      

      Attachments

        Issue Links

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

          Activity

            People

              kevin.cherkauer Kevin Cherkauer (Inactive)
              Sitaram.Vemulapalli Sitaram Vemulapalli
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty