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

[Flex] valid Flex index not sargable for flex query

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Yes

    Description

      Build: 7.2.0-1108

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

      {
        "type": "fulltext-index",
        "name": "default_index",
        "uuid": "",
        "sourceType": "gocbcore",
        "sourceName": "default",
        "sourceUUID": "",
        "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 Flex queries not using FTS indexes:

      SELECT META().id FROM `default` USE INDEX (USING FTS, USING GSI) WHERE address.ecpdId="1" ORDER BY META().id LIMIT 100
      SELECT META().id, email FROM `default` USE INDEX (USING FTS, USING GSI) WHERE address.ecpdId="3" OR address.applicationId=300 ORDER BY email,META().id LIMIT 10
      SELECT META().id, address.applicationId FROM `default` USE INDEX (USING FTS, USING GSI) WHERE address.ecpdId="3" AND address.deviceTypeId=9 ORDER BY address.applicationId,META().id LIMIT 100
      SELECT META().id, address.applicationId FROM `default` USE INDEX (USING FTS, USING GSI) WHERE address.applicationId = 1 AND address.deviceTypeId=9 AND address.deviceStatus=0 ORDER BY address.applicationId LIMIT 100
      
      

      Explain of one of the query:

      {
          "optimizer_hints": {
              "hints_not_followed": [
                  "INDEX(default ): INDEX hint cannot be followed",
                  "INDEX_FTS(default ): INDEX_FTS hint cannot be followed"
              ]
          },
          "plan": {
              "#operator": "Sequence",
              "~children": [
                  {
                      "#operator": "Sequence",
                      "~children": [
                          {
                              "#operator": "PrimaryScan3",
                              "index": "primary_gsi_index",
                              "index_projection": {
                                  "primary_key": true
                              },
                              "keyspace": "default",
                              "namespace": "default",
                              "using": "gsi"
                          },
                          {
                              "#operator": "Fetch",
                              "keyspace": "default",
                              "namespace": "default"
                          },
                          {
                              "#operator": "Parallel",
                              "~child": {
                                  "#operator": "Sequence",
                                  "~children": [
                                      {
                                          "#operator": "Filter",
                                          "condition": "(((((`default`.`address`).`applicationId`) = 1) and (((`default`.`address`).`deviceTypeId`) = 9)) and (((`default`.`address`).`deviceStatus`) = 0))"
                                      },
                                      {
                                          "#operator": "InitialProject",
                                          "result_terms": [
                                              {
                                                  "expr": "(meta(`default`).`id`)"
                                              },
                                              {
                                                  "expr": "((`default`.`address`).`applicationId`)"
                                              }
                                          ]
                                      }
                                  ]
                              }
                          }
                      ]
                  },
                  {
                      "#operator": "Order",
                      "limit": "100",
                      "sort_terms": [
                          {
                              "expr": "((`default`.`address`).`applicationId`)"
                          }
                      ]
                  },
                  {
                      "#operator": "Limit",
                      "expr": "100"
                  }
              ]
          }
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              ritam.sharma Ritam Sharma
              girish.benakappa Girish Benakappa
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty