blob: d507b86490690e4ebf0bae817c1e81b19c3c50e6 (
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
|
// Basic test to ensure that the keysExamined and docsExamined are tracked
// correctly for updates.
var t = db.jstests_update_profile;
t.drop();
// Turn off profiling so that we can drop the profiler's collection. Then
// enable profiling again. This is OK because this test is blacklisted for the
// parallel suite.
db.setProfilingLevel(0);
db.system.profile.drop();
db.setProfilingLevel(2);
for (var i = 0; i < 5; i++) {
t.insert({x: i});
}
// No index---this update will do a collection scan.
t.update({x: {$gt: 3}}, {$set: {y: true}}, {multi: true});
printjson(t.find().toArray());
assert.eq(1,
db.system.profile.count({op: "update"}),
"expected exactly one update op in system.profile");
var prof = db.system.profile.findOne({op: "update"});
printjson(prof);
// Since we're doing a collection scan, we should have examined zero
// index keys and all 5 documents.
assert.eq(0, prof.keysExamined, "wrong keysExamined");
assert.eq(5, prof.docsExamined, "wrong docsExamined");
// Disable profiling and drop the profiler data.
db.setProfilingLevel(0);
db.system.profile.drop();
|