[SERVER-3491] queries that require nothing from document scans documents anyway on indexed queries Created: 27/Jul/11 Updated: 29/Aug/11 Resolved: 27/Jul/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 1.8.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | ttt | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
centos x64, mongo-10gen-server-1.8.2-mongodb_1 rpm |
||
| Operating System: | Linux |
| Participants: |
| Description |
|
> db.index.find( { subdomain: "sub.domain.com"}, { __id:1} ).explain(); , { "$maxElement" : 1 } ] , { "$maxElement" : 1 } ] > db.index.find( { subdomain: "sub.domain.org", folder: "" }, {subdomain:1} ).explain(); , { "$maxElement" : 1 } ] mongo returns __id in both queries anyway, does that mean mongod needs to scan for objectid in objects and uses some other reference in indexes? i'm confused - it shouldn't touch objects at all for queries like this. |
| Comments |
| Comment by ttt [ 27/Jul/11 ] |
|
i see. now that i exclude _id, indexOnly is true, but why would "nscannedObjects" be equal to "nscanned"? how do i get sure that only index is used? > db.index.find( { subdomain: "sub.domain.org", folder: "" },{_id:0,subdomain:1,folder:1,name:1} ).explain(); , { "$maxElement" : 1 } ] |
| Comment by Scott Hernandez (Inactive) [ 27/Jul/11 ] |
|
You must exclude _id to use the indexed only. See the docs here: http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-CoveredIndexes |