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

[BP to 7.0.4] - Aggregates wrongly pushed

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Yes

    Description

       upsert into default values("f01",{"c1":5, "c3":10});
      create index ix1 on default(c1,c2,c3);
      SELECT COUNT(1) FROM default AS d WHERE d.c1 =5 AND d.c3 BETWEEN 0 AND 20 AND (false OR d.c2 = false);
      {
              "$1": 1
        }
       
      SELECT d.* FROM default AS d WHERE d.c1 =5 AND d.c3 BETWEEN 0 AND 20 AND (false OR d.c2 = false);
       no results.
      

      Why aggregate query returns wrong results.

      EXPLAIN SELECT COUNT(1) FROM default AS d WHERE d.c1 =5 AND d.c3 BETWEEN 0 AND 20 AND (false OR d.c2 = false);
      {
          "requestID": "be71cf74-bec3-451a-9e8b-afd284a63ed7",
          "signature": "json",
          "results": [
          {
              "plan": {
                  "#operator": "Sequence",
                  "~children": [
                      {
                          "#operator": "IndexScan3",
                          "as": "d",
                          "covers": [
                              "cover ((`d`.`c1`))",
                              "cover ((`d`.`c2`))",
                              "cover ((`d`.`c3`))",
                              "cover ((meta(`d`).`id`))",
                              "cover (count(1))"
                          ],
                          "index": "ix1",
                          "index_group_aggs": {
                              "aggregates": [
                                  {
                                      "aggregate": "COUNT",
                                      "expr": "1",
                                      "id": 4,
                                      "keypos": -1
                                  }
                              ]
                          },
                          "index_id": "e299bc49c8ec86d7",
                          "index_projection": {
                              "entry_keys": [
                                  4
                              ]
                          },
                          "keyspace": "default",
                          "namespace": "default",
                          "spans": [
                              {
                                  "exact": true,
                                  "range": [
                                      {
                                          "high": "5",
                                          "inclusion": 3,
                                          "low": "5"
                                      },
                                      {
                                          "inclusion": 0
                                      },
                                      {
                                          "high": "20",
                                          "inclusion": 3,
                                          "low": "0"
                                      }
                                  ]
                              },
                              {
                                  "exact": true,
                                  "range": [
                                      {
                                          "high": "5",
                                          "inclusion": 3,
                                          "low": "5"
                                      },
                                      {
                                          "high": "false",
                                          "inclusion": 3,
                                          "low": "false"
                                      },
                                      {
                                          "high": "20",
                                          "inclusion": 3,
                                          "low": "0"
                                      }
                                  ]
                              }
                          ],
                          "using": "gsi"
                      },
                      {
                          "#operator": "Parallel",
                          "~child": {
                              "#operator": "Sequence",
                              "~children": [
                                  {
                                      "#operator": "InitialProject",
                                      "result_terms": [
                                          {
                                              "expr": "cover (count(1))"
                                          }
                                      ]
                                  },
                                  {
                                      "#operator": "FinalProject"
                                  }
                              ]
                          }
                      }
                  ]
              },
              "text": "SELECT COUNT(1) FROM default AS d WHERE d.c1 =5 AND d.c3 BETWEEN 0 AND 20 AND (false OR d.c2 = false);"
          }
          ],
          "status": "success",
          "metrics": {
              "elapsedTime": "2.639403ms",
              "executionTime": "2.554982ms",
              "resultCount": 1,
              "resultSize": 3701
          }
      }
      

      (false OR d.c2 = false); why not properly reduce this? Why it is not detected false positives.

      Attachments

        Issue Links

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

          Activity

            People

              ajay.bhullar Ajay Bhullar
              kamini.jagtiani Kamini Jagtiani
              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