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

[BP MB-56039 to 7.1.5] - OR clause doesn't push variable spans

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 7.1.5
    • 7.1.4
    • query
    • Security Level: Public
    • Untriaged
    • 0
    • Yes

    Description

      CREATE INDEX ix1 ON default(ticker, ts_start, ts_end);

      EXPLAIN SELECT d.* FROM default AS d WHERE d.ticker = 'BASE' AND (($1 BETWEEN d.ts_start AND d.ts_end) OR (d.ts_start BETWEEN $1 AND $2));{
          "requestID": "df051f61-f2df-4ef8-b36d-d12f644b3e9c",
          "signature": "json",
          "results": [
          {
              "plan": {
                  "#operator": "Sequence",
                  "~children": [
                      {
                          "#operator": "IndexScan3",
                          "as": "d",
                          "index": "ix1",
                          "index_id": "6fac8fd5f667b5f8",
                          "index_projection": {
                              "primary_key": true
                          },
                          "keyspace": "default",
                          "namespace": "default",
                          "spans": [
                              {
                                  "exact": true,
                                  "range": [
                                      {
                                          "high": "\"BASE\"",
                                          "inclusion": 3,
                                          "index_key": "`ticker`",
                                          "low": "\"BASE\""
                                      },
                                      {
                                          "high": "$1",
                                          "inclusion": 2,
                                          "index_key": "`ts_start`",
                                          "low": "null"
                                      }
                                  ]
                              },
                              {
                                  "exact": true,
                                  "range": [
                                      {
                                          "high": "\"BASE\"",
                                          "inclusion": 3,
                                          "index_key": "`ticker`",
                                          "low": "\"BASE\""
                                      },
                                      {
                                          "high": "$2",
                                          "inclusion": 3,
                                          "index_key": "`ts_start`",
                                          "low": "$1"
                                      }
                                  ]
                              }
                          ],
                          "using": "gsi"
                      },
                      {
                          "#operator": "Fetch",
                          "as": "d",
                          "keyspace": "default",
                          "namespace": "default"
                      },
                      {
                          "#operator": "Parallel",
                          "~child": {
                              "#operator": "Sequence",
                              "~children": [
                                  {
                                      "#operator": "Filter",
                                      "condition": "(((`d`.`ticker`) = \"BASE\") and (($1 between (`d`.`ts_start`) and (`d`.`ts_end`)) or ((`d`.`ts_start`) between $1 and $2)))"
                                  },
                                  {
                                      "#operator": "InitialProject",
                                      "discard_original": true,
                                      "preserve_order": true,
                                      "result_terms": [
                                          {
                                              "expr": "`d`",
                                              "star": true
                                          }
                                      ]
                                  }
                              ]
                          }
                      }
                  ]
              },
              "text": "SELECT d.* FROM default AS d WHERE d.ticker = 'BASE' AND (($1 BETWEEN d.ts_start AND d.ts_end) OR (d.ts_start BETWEEN $1 AND $2));"
          }
          ],
          "status": "success",
          "metrics": {
              "elapsedTime": "1.956996ms",
              "executionTime": "1.898207ms",
              "resultCount": 1,
              "resultSize": 3466,
              "serviceLoad": 2
          }
      } 

      ts_end range is not pushed indexer. This can heavily impact because Fetch involved. 

       

      Issue Resolution
      A query plan was changed between Server releases. This meant the filter did not update the index when an OR clause pushed variable spans. The OR clause has been modified to correct this issue.

      Attachments

        Issue Links

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

          Activity

            People

              pierre.regazzoni Pierre Regazzoni
              bingjie.miao Bingjie Miao
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty