-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 7.3.3, 8.0.0-rc6
-
Component/s: None
-
None
-
Query Execution
-
ALL
Define a collection with this index:
> db.repro.createIndex({ office: 1, archive_status: 1, audit_status: 1, case_status: 1, spek_appl_submit_type_id: 1 })
Then run an aggregation where an $and clause is excluding one of the items in the $in array for the spek_appl_submit_type_id field so that the plan that gets cached is using a single interval index scan
> db.repro.aggregate([{"$match":{"$and":[{"$and":[{"spek_appl_submit_type_id":{"$in":["1","4"]}},{"case_status":{"$in":["pending"]}},{"audit_status":{"$in":["initial"]}},{"archive_status":{"$in":["pending"]}}]},{"office":{"$in":[ObjectId("6596d6f647b62570aa1c975e")]}},{"spek_appl_submit_type_id":{"$ne":"4"}}]}},{"$count":"total"}])
Then run the same query but replacing the "4" with a "2" so that the query now requires two index scan intervals
> db.repro.aggregate([{"$match":{"$and":[{"$and":[{"spek_appl_submit_type_id":{"$in":["1","2"]}},{"case_status":{"$in":["pending"]}},{"audit_status":{"$in":["initial"]}},{"archive_status":{"$in":["pending"]}}]},{"office":{"$in":[ObjectId("6596d6f647b62570aa1c975e")]}},{"spek_appl_submit_type_id":{"$ne":"4"}}]}},{"$count":"total"}]) uncaught exception: Error: command failed: { "ok" : 0, "errmsg" : "Can only bind a single index interval", "code" : 6584700, "codeName" : "Location6584700" }
- related to
-
SERVER-84369 Ineligible query reuses plan cache entry for a COUNT_SCAN (SBE only)
- Closed