[SERVER-10959] indexOnly is wrong sometimes Created: 30/Sep/13  Updated: 10/Dec/14  Resolved: 30/Sep/13

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

Type: Bug Priority: Trivial - P5
Reporter: Markus Ostertag Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-5759 indexOnly in explain() is not reporte... Closed
Operating System: ALL
Participants:

 Description   

The indexOnly in an explain() is set to true even if the query needs fields which aren't in the index.
This is the example collection:

db.test.insert([{a:1,c:1},{a:2,c:1}])
db.test.ensureIndex({c:1})
db.test.find({a:1,c:1},{_id:0,c:1}).explain()

This is what the explain looks like:

> db.test.find({a:1,c:1},{_id:0,c:1}).explain()
{
        "cursor" : "BtreeCursor c_1",
        "isMultiKey" : false,
        "n" : 1,
        "nscannedObjects" : 2,
        "nscanned" : 2,
        "nscannedObjectsAllPlans" : 4,
        "nscannedAllPlans" : 4,
        "scanAndOrder" : false,
        "indexOnly" : true,
        "nYields" : 0,
        "nChunkSkips" : 0,
        "millis" : 0,
        "indexBounds" : {
                "c" : [
                        [
                                1,
                                1
                        ]
        ]
        },
        "server" : "server:27017"
}

indexOnly is set to true but MongoDB has to query on field a which is not part of the index c_1 - so it has to be false.



 Comments   
Comment by Stennie Steneker (Inactive) [ 30/Sep/13 ]

Hi Markus,

Thank you for the feedback.

This issue has already been reported as SERVER-5759.

Regards,
Stephen

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