blob: 3bcc7b2302df0f518bde73d3ffe627167b36a5c8 (
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
25
26
27
28
29
30
31
32
33
34
35
36
|
// @tags: [
// assumes_balancer_off,
// assumes_read_concern_local,
// ]
(function() {
'use strict';
const t = db.index_check7;
t.drop();
assert.commandWorked(t.createIndex({x: 1}));
let docs = [];
for (let i = 0; i < 100; i++) {
docs.push({_id: i, x: i});
}
assert.commandWorked(t.insert(docs));
let explainResult = t.find({x: 27}).explain(true);
assert.eq(1,
explainResult.executionStats.totalKeysExamined,
'explain x=27 with index {x : 1}: ' + tojson(explainResult));
assert.commandWorked(t.createIndex({x: -1}));
explainResult = t.find({x: 27}).explain(true);
assert.eq(1,
explainResult.executionStats.totalKeysExamined,
'explain x=27 with indexes {x : 1} and {x: -1}: ' + tojson(explainResult));
explainResult = t.find({x: {$gt: 59}}).explain(true);
assert.eq(40,
explainResult.executionStats.totalKeysExamined,
'explain x>59 with indexes {x : 1} and {x: -1}: ' + tojson(explainResult));
})();
|