Files
mongo/jstests/core/profile5.js
David Storch 1574457c5f SERVER-19566 convert OP_QUERY profiler entries to look like the find command
Includes the following changes to profiler entries for queries:

-- The query field will contain find command parameters, e.g.
{find: <coll>, filter: {...}}.
-- Renames 'nscanned' to 'keysExamined' and 'nscannedObjects' to 'docsExamined'.
-- Renames 'scanAndOrder' to 'hasSortStage'.
-- Removes the top-level ntoreturn and ntoskip fields. Skip, limit, and
batchSize info will be present in the 'query' field instead.
2015-09-03 16:06:13 -04:00

36 lines
1.1 KiB
JavaScript

// 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();