blob: 2eaff689c3bc47c342ccde5ed97b653aab4b775c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/**
* Test that, in a conjunction of two separate multikey predicates, each predicate can match
* a separate array element. This means we must avoid satisfying both predicates with one
* multikey index scan.
*
* Reproduces SERVER-71524.
*/
(function() {
"use strict";
const coll = db.query_golden_multiple_traverse_single_scan;
coll.drop();
assert.commandWorked(coll.insert({a: [{x: 1}, {y: 1}]}));
assert.commandWorked(coll.insert(Array.from({length: 100}, () => ({}))));
assert.commandWorked(coll.createIndex({a: 1}));
// Both predicates match, by matching different elements of 'a'.
// But the index will contain separate entries for {x: 1} and {y: 1}.
// An incorrect plan would force each index entry to match both predicates,
// returning an empty result-set.
show(coll.find({'a.x': 1, 'a.y': 1}, {_id: 0}));
})();
|