[SERVER-4161] nscannedObjects is not calculated properly for covered index queries Created: 27/Oct/11  Updated: 11/Jul/16  Resolved: 30/Sep/12

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Querying
Affects Version/s: 2.0.1
Fix Version/s: 2.3.0

Type: Bug Priority: Major - P3
Reporter: Sridhar Nanjundeswaran Assignee: Aaron Staple
Resolution: Done Votes: 1
Labels: coveredIndex, nscannedObjects
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 x64, MongoDB 2.0.1


Issue Links:
Duplicate
is duplicated by SERVER-8300 Covered multi-key query still scans Closed
Related
related to SERVER-8575 slowNightly tests failing on covered_... Closed
related to SERVER-5759 indexOnly in explain() is not reporte... Closed
related to SERVER-5019 covered indexes are not implemented f... Closed
Operating System: ALL
Participants:

 Description   

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).

-----------------------------------

Expected nscannedObjects to be 0 for a covered index query but it is 1.

for (var i = 1; i < 11; i++) {
db.cindextest.insert(

{foo:i,bar:i*10}

)
}
db.cindextest.ensureIndex(

{foo:1}

)

> 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" :

{ "foo" : [ [ 1, 1 ] ] }

}



 Comments   
Comment by auto [ 20/Feb/13 ]

Author:

{u'date': u'2013-02-19T23:35:49Z', u'name': u'Sridhar Nanjundeswaran', u'email': u'sridhar@10gen.com'}

Message: Tests for SERVER-4161. Covered index query for geo and hashed indexes

Signed-off-by: Ian Whalen <ian.whalen@gmail.com>
Branch: master
https://github.com/mongodb/mongo/commit/3f920f0e2bcd88a8b3f76239d9d2da5c1a061702

Comment by auto [ 14/Feb/13 ]

Author:

{u'date': u'2013-02-15T06:26:56Z', u'name': u'aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-8575 SERVER-4161 SERVER-5759 Disable descriptive testing of erroneous indexOnly reporting when the behavior is inconsistent in a sharded environment. Fixes sharding_passthrough/covered_index_negative1 test.
Branch: master
https://github.com/mongodb/mongo/commit/2d71e6ab2d42c3c1cc31d42e579dec8041f6cca4

Comment by auto [ 14/Feb/13 ]

Author:

{u'date': u'2013-02-14T00:25:30Z', u'name': u'Sridhar Nanjundeswaran', u'email': u'sridhar@10gen.com'}

Message: SERVER-4161 Covered index query tests

Signed-off-by: Ian Whalen <ian.whalen@gmail.com>
Branch: master
https://github.com/mongodb/mongo/commit/d013b483c917ff4a48c002c0c0a133a1f62f55cf

Comment by auto [ 28/Sep/12 ]

Author:

{u'date': u'2012-09-27T20:42:47-07:00', u'email': u'aaron@10gen.com', u'name': u'Aaron'}

Message: SERVER-4161 Exclude explainc test from multi version testing.
Branch: master
https://github.com/mongodb/mongo/commit/99bf4aaa6722b5dfd0787c2682e0144cb1325a01

Comment by auto [ 28/Sep/12 ]

Author:

{u'date': u'2012-09-24T10:57:29-07:00', u'email': u'aaron@10gen.com', u'name': u'Aaron'}

Message: SERVER-4161 Report nscannedObjects properly when covered indexes are used.
Branch: master
https://github.com/mongodb/mongo/commit/6e555988bff53d807635ef59796c45c824b770ba

Comment by auto [ 28/Sep/12 ]

Author:

{u'date': u'2012-09-21T16:04:40-07:00', u'email': u'aaron@10gen.com', u'name': u'Aaron'}

Message: SERVER-4161 Add ResultDetails struct for candidate result document retrieval metadata.
Branch: master
https://github.com/mongodb/mongo/commit/3f02a780112135da725070a8c43b2d8195a9f434

Comment by auto [ 20/Sep/12 ]

Author:

{u'date': u'2012-09-01T20:45:59-07:00', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-4161 Convert ResponseBuildStrategy::handleMatch() arguments to meet coding standards.
Branch: master
https://github.com/mongodb/mongo/commit/54d3bc66d1931701fbe972eb0a602290daa3b6fb

Generated at Thu Feb 08 03:05:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.