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

[Flex]Flex Query using random sargable index not optimal index

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Unknown

    Description

      Build: 7.0.1 build 5979

      Create a 3 node cluster with services kv, search, query+search
      Load travel-sample
      Create below 2 indexes:
      Index test - dynamic index with keyword analyzer

      {
        "type": "fulltext-index",
        "name": "test",
        "uuid": "2561e32b7aac5dac",
        "sourceType": "gocbcore",
        "sourceName": "travel-sample",
        "sourceUUID": "5c59f3f94f2bfc1533e1ca9cba6b5a37",
        "planParams": {
          "maxPartitionsPerPIndex": 41,
          "indexPartitions": 25
        },
        "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": {
              "dynamic": true,
              "enabled": true
            },
            "default_type": "_default",
            "docvalues_dynamic": false,
            "index_dynamic": true,
            "store_dynamic": false,
            "type_field": "_type"
          },
          "store": {
            "indexType": "scorch",
            "segmentVersion": 15
          }
        },
        "sourceParams": {}
      }
      

      index test1 - default mapping index with country field

      {
        "type": "fulltext-index",
        "name": "test1",
        "uuid": "1e1e53f55e42b0cc",
        "sourceType": "gocbcore",
        "sourceName": "travel-sample",
        "sourceUUID": "5c59f3f94f2bfc1533e1ca9cba6b5a37",
        "planParams": {
          "maxPartitionsPerPIndex": 52,
          "indexPartitions": 20
        },
        "params": {
          "doc_config": {
            "docid_prefix_delim": "",
            "docid_regexp": "",
            "mode": "type_field",
            "type_field": "type"
          },
          "mapping": {
            "analysis": {},
            "default_analyzer": "standard",
            "default_datetime_parser": "dateTimeOptional",
            "default_field": "_all",
            "default_mapping": {
              "dynamic": false,
              "enabled": true,
              "properties": {
                "country": {
                  "dynamic": false,
                  "enabled": true,
                  "fields": [
                    {
                      "analyzer": "keyword",
                      "docvalues": true,
                      "include_in_all": true,
                      "include_term_vectors": true,
                      "index": true,
                      "name": "country",
                      "store": true,
                      "type": "text"
                    }
                  ]
                }
              }
            },
            "default_type": "_default",
            "docvalues_dynamic": false,
            "index_dynamic": true,
            "store_dynamic": false,
            "type_field": "_type"
          },
          "store": {
            "indexType": "scorch",
            "segmentVersion": 15
          }
        },
        "sourceParams": {}
      }
      

      Running below query in loop:

      select meta().id from `travel-sample` USE INDEX(USING FTS) where country = "United States"
      

      Query does not use optimal index:test1 all the time. From the query logs:

       
      _time=2021-08-03T09:17:26.221-07:00 _level=INFO _msg=response_handler: n1fty[test1/travel-sample-1628007446179549017] "ac19653e-6b23-4e2b-ad88-bbe54947fafd" finished backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069682226990  
      _time=2021-08-03T09:17:26.338-07:00 _level=INFO _msg=response_handler: buffer overflow [cap 512 len 469], initiating backfill 
      _time=2021-08-03T09:17:26.338-07:00 _level=INFO _msg=response_handler: n1fty[test1/travel-sample-1628007446331090724] "4d5cf1a2-1c44-402c-876b-ae3ead2aa02a" started backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069131306165 
      _time=2021-08-03T09:17:26.374-07:00 _level=INFO _msg=response_handler: n1fty[test1/travel-sample-1628007446331090724] "4d5cf1a2-1c44-402c-876b-ae3ead2aa02a" finished backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069131306165  
      _time=2021-08-03T09:17:26.489-07:00 _level=INFO _msg=response_handler: buffer overflow [cap 512 len 460], initiating backfill 
      _time=2021-08-03T09:17:26.489-07:00 _level=INFO _msg=response_handler: n1fty[test/travel-sample-1628007446485374741] "8ef31746-58ce-471a-ac7a-d1af731e5434" started backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069155477136 
      _time=2021-08-03T09:17:26.528-07:00 _level=INFO _msg=response_handler: n1fty[test/travel-sample-1628007446485374741] "8ef31746-58ce-471a-ac7a-d1af731e5434" finished backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069155477136  
      _time=2021-08-03T09:17:26.632-07:00 _level=INFO _msg=response_handler: buffer overflow [cap 512 len 435], initiating backfill 
      _time=2021-08-03T09:17:26.632-07:00 _level=INFO _msg=response_handler: n1fty[test1/travel-sample-1628007446629089465] "2784d46d-4270-412e-a283-b04a1d90071e" started backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069087351983 
      _time=2021-08-03T09:17:26.673-07:00 _level=INFO _msg=response_handler: n1fty[test1/travel-sample-1628007446629089465] "2784d46d-4270-412e-a283-b04a1d90071e" finished backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069087351983  
      _time=2021-08-03T09:17:26.775-07:00 _level=INFO _msg=response_handler: buffer overflow [cap 512 len 504], initiating backfill 
      _time=2021-08-03T09:17:26.776-07:00 _level=INFO _msg=response_handler: n1fty[test/travel-sample-1628007446771336963] "39fcffb7-4677-45cd-9df2-7706e8baa95d" started backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069419569730 
      _time=2021-08-03T09:17:26.818-07:00 _level=INFO _msg=response_handler: n1fty[test/travel-sample-1628007446771336963] "39fcffb7-4677-45cd-9df2-7706e8baa95d" finished backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069419569730  
      _time=2021-08-03T09:17:26.928-07:00 _level=INFO _msg=response_handler: buffer overflow [cap 512 len 462], initiating backfill 
      _time=2021-08-03T09:17:26.928-07:00 _level=INFO _msg=response_handler: n1fty[test1/travel-sample-1628007446924323490] "414575de-0fe0-4321-a4da-a886c54401ae" started backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069535600313 
      _time=2021-08-03T09:17:26.968-07:00 _level=INFO _msg=response_handler: n1fty[test1/travel-sample-1628007446924323490] "414575de-0fe0-4321-a4da-a886c54401ae" finished backfill for /opt/couchbase/var/lib/couchbase/tmp/search-results106069535600313  
      

      Logs:

      https://cb-jira.s3.us-east-2.amazonaws.com/logs/test/collectinfo-2021-08-03T161925-ns_1%40172.23.96.141.zip
      https://cb-jira.s3.us-east-2.amazonaws.com/logs/test/collectinfo-2021-08-03T161925-ns_1%40172.23.97.211.zip
      https://cb-jira.s3.us-east-2.amazonaws.com/logs/test/collectinfo-2021-08-03T161925-ns_1%40172.23.97.212.zip

      Attachments

        For Gerrit Dashboard: MB-47713
        # Subject Branch Project Status CR V

        Activity

          People

            evgeny.makarenko Evgeny Makarenko (Inactive)
            girish.benakappa Girish Benakappa
            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