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

[Flex] Flex query results with order, offset and limit not matching with GSI results

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Yes

    Description

      Build: 7.0.4-7237
      Not seen this issue with 7.0.4-7236

      Dataset: https://s3-us-west-1.amazonaws.com/qebucket/testrunner/data/napa_dataset.txt.gz
      FTS index:

      {
        "type": "fulltext-index",
        "name": "default_index",
        "uuid": "15de04e082dbca1b",
        "sourceType": "gocbcore",
        "sourceName": "default",
        "sourceUUID": "97f6b9b4d21ed4190d21277b49c9a165",
        "planParams": {
          "maxPartitionsPerPIndex": 171
        },
        "params": {
          "doc_config": {
            "docid_prefix_delim": "",
            "docid_regexp": "",
            "mode": "type_field",
            "type_field": "type"
          },
          "mapping": {
            "analysis": {},
            "default_analyzer": "keyword",
            "default_datetime_parser": "dateTimeOptional",
            "default_field": "_all",
            "default_mapping": {
              "default_analyzer": "keyword",
              "dynamic": true,
              "enabled": true
            },
            "default_type": "_default",
            "docvalues_dynamic": true,
            "index_dynamic": true,
            "store_dynamic": false,
            "type_field": "type"
          },
          "store": {
            "indexType": "scorch",
            "mossStoreOptions": {},
            "segmentVersion": 15
          }
        },
        "sourceParams": {}
      }
      

      Below GSI query results with 100 docs:

      SELECT meta().id FROM default USE INDEX ( USING GSI) WHERE ANY c IN children SATISFIES c.gender = "F" AND (c.age > 5 AND c.age <15) OR c.first_name LIKE "a%" END ORDER BY address.country,META().id OFFSET 500 LIMIT 100
       
      id
      "napa_10009814"
      "napa_10000096"
      "napa_10000796"
      "napa_10001271"
      "napa_10002219"
      "napa_10002414"
      "napa_10002595"
      "napa_10003869"
      "napa_10004693"
      "napa_10005008"
      "napa_10006603"
      "napa_10006890"
      "napa_10006982"
      "napa_10007656"
      "napa_10001436"
      "napa_10002851"
      "napa_10004756"
      "napa_10006941"
      "napa_10000148"
      "napa_10000631"
      "napa_10003036"
      "napa_10003073"
      "napa_10004874"
      "napa_10005908"
      "napa_10006585"
      "napa_10006777"
      "napa_10007248"
      "napa_10007758"
      "napa_10008349"
      "napa_10008960"
      "napa_10009662"
      "napa_10001631"
      "napa_10003054"
      "napa_10003099"
      "napa_10003503"
      "napa_10003562"
      "napa_10004653"
      "napa_10006140"
      "napa_10007378"
      "napa_10007739"
      "napa_10007952"
      "napa_10009113"
      "napa_10001282"
      "napa_10001352"
      "napa_10002081"
      "napa_10002476"
      "napa_10005459"
      "napa_10005655"
      "napa_10006480"
      "napa_10007523"
      "napa_10008424"
      "napa_10009302"
      "napa_10009852"
      "napa_10000116"
      "napa_10000648"
      "napa_10000713"
      "napa_10001374"
      "napa_10002284"
      "napa_10002289"
      "napa_10002370"
      "napa_10002558"
      "napa_10003323"
      "napa_10003330"
      "napa_10003753"
      "napa_10004302"
      "napa_10004424"
      "napa_10004645"
      "napa_10004751"
      "napa_10004865"
      "napa_10004903"
      "napa_10005573"
      "napa_10005806"
      "napa_10005897"
      "napa_10007355"
      "napa_10007659"
      "napa_10007764"
      "napa_10007829"
      "napa_10008811"
      "napa_10008824"
      "napa_10009648"
      "napa_10001565"
      "napa_10001825"
      "napa_10003428"
      "napa_10004526"
      "napa_10005216"
      "napa_10006303"
      "napa_10007437"
      "napa_10008473"
      "napa_10009107"
      "napa_10001072"
      "napa_10001910"
      "napa_10003497"
      "napa_10005312"
      "napa_10007720"
      "napa_10008149"
      "napa_10003647"
      "napa_10005919"
      "napa_10008614"
      "napa_10009147"
      "napa_10000652"
      
      

      Below Flex query results in 73 docs

      SELECT meta().id FROM default USE INDEX (USING FTS, USING GSI) WHERE ANY c IN children SATISFIES c.gender = "F" AND (c.age > 5 AND c.age <15) OR c.first_name LIKE "a%" END ORDER BY address.country,META().id OFFSET 500 LIMIT 100
       
      id
      "napa_10003155"
      "napa_10003527"
      "napa_10003896"
      "napa_10004272"
      "napa_10004966"
      "napa_10005640"
      "napa_10007520"
      "napa_10007765"
      "napa_10007894"
      "napa_10008821"
      "napa_10009681"
      "napa_10009855"
      "napa_10000261"
      "napa_10000694"
      "napa_10002575"
      "napa_10004523"
      "napa_10006344"
      "napa_10006820"
      "napa_10008250"
      "napa_10008512"
      "napa_10009529"
      "napa_10000386"
      "napa_10002474"
      "napa_10003113"
      "napa_10003931"
      "napa_10004097"
      "napa_10004380"
      "napa_10004566"
      "napa_10004723"
      "napa_10005794"
      "napa_10006634"
      "napa_10006678"
      "napa_10007452"
      "napa_10007454"
      "napa_10001233"
      "napa_10001724"
      "napa_10001958"
      "napa_10002384"
      "napa_10002390"
      "napa_10006342"
      "napa_10007386"
      "napa_10007836"
      "napa_10008288"
      "napa_10008802"
      "napa_10008940"
      "napa_10009111"
      "napa_10001286"
      "napa_10001315"
      "napa_10001949"
      "napa_10002140"
      "napa_10005137"
      "napa_10005842"
      "napa_10006753"
      "napa_10006913"
      "napa_10007302"
      "napa_10007669"
      "napa_10009179"
      "napa_10009399"
      "napa_10009477"
      "napa_10009487"
      "napa_10000119"
      "napa_10002115"
      "napa_10003159"
      "napa_10004809"
      "napa_10004977"
      "napa_10005313"
      "napa_10006377"
      "napa_10006784"
      "napa_10007680"
      "napa_10007867"
      "napa_10008020"
      "napa_10009265"
      "napa_10009875"
      
      

      Explain plan of Flex query:

      {
          "#operator": "Sequence",
          "~children": [
              {
                  "#operator": "Sequence",
                  "~children": [
                      {
                          "#operator": "IndexFtsSearch",
                          "index": "default_index",
                          "index_id": "15de04e082dbca1b",
                          "keyspace": "default",
                          "namespace": "default",
                          "search_info": {
                              "field": "\"\"",
                              "limit": "100",
                              "offset": "500",
                              "options": "{\"index\": \"default_index\"}",
                              "order": [
                                  "address.country",
                                  "_id"
                              ],
                              "outname": "out",
                              "query": "{\"from\": 500, \"query\": {\"disjuncts\": [{\"conjuncts\": [{\"field\": \"children.gender\", \"term\": \"F\"}, {\"field\": \"children.age\", \"inclusive_max\": false, \"inclusive_min\": false, \"max\": 15, \"min\": 5}]}, {\"field\": \"children.first_name\", \"inclusive_max\": false, \"inclusive_min\": true, \"max\": \"b\", \"min\": \"a\"}]}, \"score\": \"none\", \"size\": 100, \"sort\": [\"address.country\", \"_id\"]}"
                          },
                          "using": "fts"
                      },
                      {
                          "#operator": "Fetch",
                          "keyspace": "default",
                          "namespace": "default"
                      },
                      {
                          "#operator": "Parallel",
                          "maxParallelism": 1,
                          "~child": {
                              "#operator": "Sequence",
                              "~children": [
                                  {
                                      "#operator": "Filter",
                                      "condition": "any `c` in (`default`.`children`) satisfies ((((`c`.`gender`) = \"F\") and ((5 < (`c`.`age`)) and ((`c`.`age`) < 15))) or ((`c`.`first_name`) like \"a%\")) end"
                                  },
                                  {
                                      "#operator": "InitialProject",
                                      "result_terms": [
                                          {
                                              "expr": "(meta(`default`).`id`)"
                                          }
                                      ]
                                  }
                              ]
                          }
                      }
                  ]
              },
              {
                  "#operator": "Limit",
                  "expr": "100"
              }
          ]
      }
      

      Attachments

        Activity

          People

            girish.benakappa Girish Benakappa
            girish.benakappa Girish Benakappa
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty