-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
Copy pathnested_or_duplicate_predicates_index_scan.js
52 lines (44 loc) · 1.43 KB
/
nested_or_duplicate_predicates_index_scan.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Test a nested $or query which reproduces SERVER-84013, a bug in the subplanner. This bug had to
* do with the subplanner assuming that multiple invocations of MatchExpression::optimize() yielded
* the same expressions, which turns out not to be the case. The queries in this regression test
* excerise the $or -> $in rewrite which produce new $in expressions which themselves could be
* further optimized.
*/
import {show} from "jstests/libs/golden_test.js";
import {resetCollection} from "jstests/query_golden/libs/utils.js";
const coll = db.server84013;
const docs = [
{Country: {_id: "US"}, State: "California", City: "SanFrancisco"},
{Country: {_id: "US"}, State: "NewYork", City: "Buffalo"},
];
const indexes = [{"Country._id": 1, "State": 1}];
resetCollection(coll, docs, indexes);
function runTest(pred) {
jsTestLog(`find(${tojson(pred)})`);
show(coll.find(pred));
}
runTest({
"$or": [
{"Country._id": "DNE"},
{
"Country._id": "US",
"State": "California",
"$or": [{"City": "SanFrancisco"}, {"City": {"$in": ["SanFrancisco"]}}]
}
]
});
runTest({
"$or": [
{"Country._id": "DNE"},
{
"Country._id": "US",
"State": "California",
"$or": [
{"City": "SanFrancisco"},
{"City": {$in: ["SanFrancisco"]}},
{"Country._id": "DNE"},
]
},
]
});