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

Query: aggregate pushdown is missed

    XMLWordPrintable

Details

    Description

      Build 6.5.0-4219

      Having index:

      CREATE INDEX `ix3` ON `default`((distinct (array (`a`.`y`) for `a` in `arr` end)) DESC)

      and running query

      EXPLAIN SELECT COUNT(DISTINCT a.y) FROM default d UNNEST d.arr As a WHERE a.y = 10

      expect to find aggregate pushdown in execution plan, but it is missed:

      [
        {
          "plan": {
            "#operator": "Sequence",
            "~children": [
              {
                "#operator": "IndexScan3",
                "as": "d",
                "covers": [
                  "cover ((`a`.`y`))",
                  "cover ((meta(`d`).`id`))"
                ],
                "filter_covers": {
                  "cover (((`d`.`arr`) < {}))": true,
                  "cover (([] <= (`d`.`arr`)))": true,
                  "cover (is_array((`d`.`arr`)))": true
                },
                "index": "ix3",
                "index_id": "6644faca9b73ead8",
                "keyspace": "default",
                "namespace": "default",
                "spans": [
                  {
                    "exact": true,
                    "range": [
                      {
                        "high": "10",
                        "inclusion": 3,
                        "low": "10"
                      }
                    ]
                  }
                ],
                "using": "gsi"
              },
              {
                "#operator": "Parallel",
                "~child": {
                  "#operator": "Sequence",
                  "~children": [
                    {
                      "#operator": "Filter",
                      "condition": "(cover ((`a`.`y`)) = 10)"
                    },
                    {
                      "#operator": "InitialGroup",
                      "aggregates": [
                        "count(distinct cover ((`a`.`y`)))"
                      ],
                      "group_keys": []
                    }
                  ]
                }
              },
              {
                "#operator": "IntermediateGroup",
                "aggregates": [
                  "count(distinct cover ((`a`.`y`)))"
                ],
                "group_keys": []
              },
              {
                "#operator": "FinalGroup",
                "aggregates": [
                  "count(distinct cover ((`a`.`y`)))"
                ],
                "group_keys": []
              },
              {
                "#operator": "Parallel",
                "~child": {
                  "#operator": "Sequence",
                  "~children": [
                    {
                      "#operator": "InitialProject",
                      "result_terms": [
                        {
                          "expr": "count(distinct cover ((`a`.`y`)))"
                        }
                      ]
                    },
                    {
                      "#operator": "FinalProject"
                    }
                  ]
                }
              }
            ]
          },
          "text": "SELECT COUNT(DISTINCT a.y) FROM default d UNNEST d.arr As a WHERE a.y = 10"
        }
      ]
      

      Attachments

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

        Activity

          People

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