ISSUE SUMMARY
The update system sets nscanned and nscannedObjects simply by incrementing counters. This is at odds with the query system's definition of nscanned as "the number of keys examined" and nscannedObjects as "the number of documents examined".
These values are collected and made available through the profiler and slow query log.
USER IMPACT
The profiler and the slow query log may show incorrect values for nscanned and nscannedObjects for update operations. These values should be larger than reported.
WORKAROUNDS
N/A
AFFECTED VERSIONS
MongoDB 2.6 production releases up to 2.6.3 are affected by this issue.
FIX VERSION
The fix is included in the 2.6.4 production release.
RESOLUTION DETAILS
Retrieve the correct values for nscanned and nscannedObjects from underlying query runner.
Original description
The nscanned value for multi updates is not correct for collection scans (no index present). nscanned seems to be the number of matched documents instead of the number of scanned documents (= all existing documents in the collection).
Set up a sample dataset as described under "Steps to reproduce". Then run the multi update and look at the system.profile output:
db.t.update( { x : { $lt : 3 } }, { $set : { "changed" : true } } , { multi: true } ) db.system.profile.find().pretty()
The expectation is that the profile shows nscanned: 5 (all documents in the collection), but it only shows 2.
db.system.profile.find().pretty() { "op" : "update", "ns" : "test.t", "query" : { "x" : { "$lt" : 3 } }, "updateobj" : { "$set" : { "changed" : true } }, "nscanned" : 2, "nscannedObjects" : 2, "nMatched" : 2, "nModified" : 2, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(0), "w" : NumberLong(154) }, "timeAcquiringMicros" : { "r" : NumberLong(0), "w" : NumberLong(5) } }, "millis" : 0, "execStats" : { }, "ts" : ISODate("2014-04-29T18:24:23.452Z"), "client" : "127.0.0.1", "allUsers" : [ ], "user" : "" }
This was working in 2.4.10 and is a regression.
- is duplicated by
-
SERVER-14171 nscanned and nscannedObjects misreported for update() operations using BasicCursor
- Closed
- related to
-
SERVER-15106 Incorrect nscanned and nscannedObjects for idhack updates in 2.6.4 profiler or slow query log
- Closed