[SERVER-10279] a problem about covering a index Created: 22/Jul/13  Updated: 10/Dec/14  Resolved: 23/Jul/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Chao Wei Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

i read the document about index of Mongodb.
It says:
An index covers (page 324) a query, a covered query, when:
• all the fields in the query (page 42) are part of that index, and
• all the fields returned in the documents that match the query are in the same index

but i ensure an index on one field, and can cover the index with the following query:
1) db.sb.ensureIndex(

{'wei':1}

)
2) db.sb.find(

{'wei':'www','name':'wu'}

).explain()
{
"cursor" : "BtreeCursor wei_1",
"isMultiKey" : false,
"n" : 1,
"nscannedObjects" : 1,
"nscanned" : 1,
"nscannedObjectsAllPlans" : 2,
"nscannedAllPlans" : 2,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" :

{ "wei" : [ [ "www", "www" ] ] }

,
"server" : "srv03.lan.sankuai.com:27017"
}
the explain show the index is covered.
anyone tell me why?



 Comments   
Comment by Daniel Pasette (Inactive) [ 23/Jul/13 ]

This explain output does not show that the query is covered.

The "indexOnly" field indicates that the query is satisfied from the index alone.

See the documentation of the explain field here: http://docs.mongodb.org/manual/reference/method/cursor.explain/#explain.indexOnly

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