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

N1QL: Wrong span shown in explain for NOT queries

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 4.5.0
    • 4.5.0
    • query
    • Untriaged
    • Unknown

    Description

      Query which gives correct result:

      explain SELECT COUNT FROM simple_table WHERE ((decimal_field1 < 4938) OR ((decimal_field1 > 4938) OR (decimal_field1 <= 4938))) ;

      Output:
      [
      {
      "plan": {
      "#operator": "Sequence",
      "~children": [
      {
      "#operator": "DistinctScan",
      "scan": {
      "#operator": "IndexScan",
      "covers": [
      "cover ((`simple_table`.`decimal_field1`))",
      "cover ((meta(`simple_table`).`id`))"
      ],
      "index": "simple_table_idx_decimal_field1",
      "keyspace": "simple_table",
      "namespace": "default",
      "spans": [
      {
      "Range":

      { "High": [ "4938" ], "Inclusion": 0 }

      },
      {
      "Range":

      { "Inclusion": 0, "Low": [ "4938" ] }

      },
      {
      "Range":

      { "High": [ "4938" ], "Inclusion": 2 }

      }
      ],
      "using": "gsi"
      }
      },
      {
      "#operator": "Parallel",
      "~child": {
      "#operator": "Sequence",
      "~children": [

      { "#operator": "Filter", "condition": "((cover ((`simple_table`.`decimal_field1`)) < 4938) or ((4938 < cover ((`simple_table`.`decimal_field1`))) or (cover ((`simple_table`.`decimal_field1`)) <= 4938)))" }

      ,

      { "#operator": "InitialGroup", "aggregates": [ "count(*)" ], "group_keys": [] }

      ]
      }
      },

      { "#operator": "IntermediateGroup", "aggregates": [ "count(*)" ], "group_keys": [] }

      ,

      { "#operator": "FinalGroup", "aggregates": [ "count(*)" ], "group_keys": [] }

      ,
      {
      "#operator": "Parallel",
      "~child": {
      "#operator": "Sequence",
      "~children": [
      {
      "#operator": "InitialProject",
      "result_terms": [

      { "expr": "count(*)" }

      ]
      },

      { "#operator": "FinalProject" }

      ]
      }
      }
      ]
      },
      "text": "SELECT COUNT FROM simple_table WHERE ((decimal_field1 < 4938) OR ((decimal_field1 > 4938) OR (decimal_field1 <= 4938))) ;"
      }
      ]

      Query which gives wrong result:
      explain SELECT COUNT FROM simple_table WHERE NOT ((decimal_field1 < 4938) OR ((decimal_field1 > 4938) OR (decimal_field1 <= 4938))) ;

      {
      "plan": {
      "#operator": "Sequence",
      "~children": [
      {
      "#operator": "IndexCountScan",
      "covers": [
      "cover ((`simple_table`.`decimal_field1`))",
      "cover ((meta(`simple_table`).`id`))"
      ],
      "index": "simple_table_idx_decimal_field1",
      "keyspace": "simple_table",
      "namespace": "default",
      "spans": [
      {
      "Range":

      { "High": [ "4938" ], "Inclusion": 3, "Low": [ "4938" ] }

      }
      ],
      "using": "gsi"
      },
      {
      "#operator": "IndexCountProject",
      "result_terms": [

      { "expr": "count(*)" }

      ]
      }
      ]
      },
      "text": "SELECT COUNT FROM simple_table WHERE not ((decimal_field1 < 4938) OR ((decimal_field1 > 4938) OR (decimal_field1 <= 4938))) ;"
      }
      ]

      Query which gives wrong result:
      SELECT bool_field1 FROM simple_table WHERE (bool_field1 == true) AND (bool_field1 == false)
      [
      {
      "plan": {
      "#operator": "Sequence",
      "~children": [
      {
      "#operator": "IndexScan",
      "covers": [
      "cover ((`simple_table`.`bool_field1`))",
      "cover ((meta(`simple_table`).`id`))"
      ],
      "index": "simple_table_idx_bool_field1",
      "keyspace": "simple_table",
      "namespace": "default",
      "spans": [
      {
      "Range":

      { "High": [ "*true*" ], "Inclusion": 3, "Low": [ "*true*" ] }

      }
      ],
      "using": "gsi"
      },
      {
      "#operator": "Parallel",
      "~child": {
      "#operator": "Sequence",
      "~children": [

      { "#operator": "Filter", "condition": "((cover ((`simple_table`.`bool_field1`)) = true) and (cover ((`simple_table`.`bool_field1`)) = false))" }

      ,
      {
      "#operator": "InitialProject",
      "result_terms": [

      { "expr": "cover ((`simple_table`.`bool_field1`))" }

      ]
      },

      { "#operator": "FinalProject" }

      ]
      }
      }
      ]
      },
      "text": "SELECT bool_field1 FROM simple_table WHERE (bool_field1 == true) AND (bool_field1 == false) ;"
      }
      ]

      Attachments

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

        Activity

          People

            Sitaram.Vemulapalli Sitaram Vemulapalli
            Prerna.Manaktala Prerna Manaktala (Inactive)
            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