-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0.1
-
Component/s: Index Maintenance, Querying
-
Environment:Windows 7 x64, MongoDB 2.0.1
-
ALL
Overview:
The 'nscannedObjects' field in the explain output for a query describes the number of documents that would be read from the data store to perform a query. (This count does not include cases where an index key is read but the document that index key comes from is not read.) The 'nscannedObjects' field is reported on a per query basis and also on a per query plan basis (in the allPlans section of the explain output).
Reporting nscannedObjects is not implemented by checking directly if the data layer has read a document, but by determining if the document would have been read at different stages of query handling on a case by case basis. Per this ticket, nscannedObjects is now reported as follows:
- for a query, the nscannedObjects count includes cases where a document is read to perform query matching, a document is read to determine if it belongs to a valid chunk, or a document would be read to return a result (including all documents used to perform an in memory sort, but not covered index projections that aren't sorted in memory).
- for a query plan, the nscannedObjects count includes cases where a document is read to perform query matching or a document must be read to return a result (as determined here <https://github.com/mongodb/mongo/blob/6e555988bff53d807635ef59796c45c824b770ba/src/mongo/db/queryoptimizercursorimpl.cpp#L271-L290>).
-----------------------------------
Expected nscannedObjects to be 0 for a covered index query but it is 1.
for (var i = 1; i < 11; i++) {
db.cindextest.insert(
)
}
db.cindextest.ensureIndex(
)
> db.cindextest.find(
{foo:1},
{foo:1,_id:0}).explain()
{
"cursor" : "BtreeCursor foo_1",
"nscanned" : 1,
"nscannedObjects" : 1, <------------- expected this to be 0
"n" : 1,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : true,
"indexBounds" :
}
- is duplicated by
-
SERVER-8300 Covered multi-key query still scans
- Closed
- related to
-
SERVER-8575 slowNightly tests failing on covered_index_negative_1.js
- Closed
-
SERVER-5759 indexOnly in explain() is not reported correctly
- Closed
-
SERVER-5019 covered indexes are not implemented for scan and order sorts
- Closed