Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-18461

Range predicates comparing against a BinData value should be covered, but are not in 2.6

    • Fully Compatible
    • ALL
    • Hide

      Create a collection with following documents

      { "_id" : BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv"), "a" : 1 }
      { "_id" : BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhz"), "a" : 2 }
      
      Create an index on {_id:1, a:1}
      
      execute the following query
      db.<collection>.find({"$and": [{"_id": {"$lte": new BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv")}},{"_id": {"$gte": new BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv")}}]}, {"_id":1, "a":1}).hint("_id_1_a_1").explain()
      
      Show
      Create a collection with following documents { "_id" : BinData(0, "AQAAAAEBAAVlbl9VSwAAAAAAAAhv" ), "a" : 1 } { "_id" : BinData(0, "AQAAAAEBAAVlbl9VSwAAAAAAAAhz" ), "a" : 2 } Create an index on {_id:1, a:1} execute the following query db.<collection>.find({ "$and" : [{ "_id" : { "$lte" : new BinData(0, "AQAAAAEBAAVlbl9VSwAAAAAAAAhv" )}},{ "_id" : { "$gte" : new BinData(0, "AQAAAAEBAAVlbl9VSwAAAAAAAAhv" )}}]}, { "_id" :1, "a" :1}).hint( "_id_1_a_1" ).explain()

      We only allow covering for predicates that can be answered exactly via an index scan. The "tightness" of the bounds is called EXACT in this case. If the bounds are not EXACT, then in order to answer the predicate we must fetch the full document and pass it through the filter.

      The 2.6 and 3.0 query engine does not consider range predicates against BinData values EXACT, which means that such queries cannot be covered. However, the 2.4 query engine would allow such predicates to be answered without fetching the document. We should restore the 2.4 behavior.

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            sharad.aggarwal@mongodb.com Sharad Aggarwal
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: