[SERVER-192] query that just returns value in index should get data from index Created: 28/Jul/09  Updated: 12/Jul/16  Resolved: 16/Nov/10

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

Type: Improvement Priority: Major - P3
Reporter: Eliot Horowitz (Inactive) Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 20
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-822 Field exclusion on _id should actuall... Closed
is depended on by SERVER-2104 covered index should support dotted f... Closed
is depended on by SERVER-2109 Query optimizer should pick plans tha... Closed
Participants:

 Description   

if you have something like
db.users.save(

{ name : "" , address... , etc... }

)
db.users.ensureIndex(

{ name : 1 }

)
and you do
db.users.find( {} ,

{ name : 1 }

)
it should only look at the index and never go to object.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 16/Nov/10 ]

Works with the caveats of the cases linked above

Comment by auto [ 16/Nov/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: use data from indexes if possivle SERVER-192
/mongodb/mongo/commit/2603a9632c21f9e56e780f57b15313ed9d8810ff

Comment by auto [ 16/Nov/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: safety for Projection's current state SERVER-192 SERVER-2104
/mongodb/mongo/commit/598af81eaa74d1ee0a398b48f3c8174c7e643098

Comment by auto [ 16/Nov/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: worked towards covered indexes SERVER-192
/mongodb/mongo/commit/fb109a067073d86dbf51baf093cf1820559e3674

Comment by auto [ 02/Nov/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: some thoughts on getting things from indexes SERVER-1502 SERVER-192
http://github.com/mongodb/mongo/commit/5f0427fdd8a466f073c5ae15d6dbbea2701b19a7

Comment by Scott Hernandez (Inactive) [ 12/May/10 ]

I'm testing on 1.5.1.

I do id only queries where I want all the info from the default _id index and it should not touch the table at all.

I am working with natural keys here so I know the values of the _id, most of the time. In most of my queries I send along a filter for _id in [values], but sometimes I need to get all the _id values to check for referential integrity in another collection (as a cleanup job).

> db.idOnly.save({_id:1})
> db.idOnly.find({},{_id:1}).explain()
{
"cursor" : "BasicCursor",
"indexBounds" : [ ],
"nscanned" : 1,
"nscannedObjects" : 1,
"n" : 1,
"millis" : 0,
"allPlans" : [

{ "cursor" : "BasicCursor", "indexBounds" : [ ] }

]
}
> db.idOnly.find({},{id:1}).hint("_id").explain()
{
"cursor" : "BtreeCursor id",
"indexBounds" : [
[
{
"_id" :

{ "$minElement" : 1 }

},
{
"_id" :

{ "$maxElement" : 1 }

}
]
],
"nscanned" : 1,
"nscannedObjects" : 1,
"n" : 1,
"millis" : 1
}

Comment by Eliot Horowitz (Inactive) [ 26/Mar/10 ]

SERVER-822 will definitely be supported for this.
So at least doing this will be possible, if not a bit annoying.

Comment by Michael Dirolf [ 26/Mar/10 ]

one possible solution to the _id problem is SERVER-822

Comment by Scott Hernandez (Inactive) [ 26/Mar/10 ]

I'm all for making _id optional; let me decide the performance ramifications when I make the query. However... the default should return the _id;

Comment by Eliot Horowitz (Inactive) [ 15/Mar/10 ]

this is complicated since we return _id no matter what.
we don't keep _id in the index for space reasons.
so we either have to not return _id or add _id to the index if we wanted to do this...
or we can add a flag to make this optional

Comment by auto [ 15/Mar/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: commited and reverted so the code exists
Revert "stalled attempt at covered index lookup SERVER-192 see case for why stalled"

This reverts commit aa6c394b72667bb59effcdb4f13a0c70202e7258.
http://github.com/mongodb/mongo/commit/b425b6bfe0e212768fc99e4a19635ecb22ab6ba5

Comment by auto [ 15/Mar/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: stalled attempt at covered index lookup SERVER-192 see case for why stalled
http://github.com/mongodb/mongo/commit/aa6c394b72667bb59effcdb4f13a0c70202e7258

Generated at Thu Feb 08 02:53:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.