Created
July 28, 2014 19:10
-
-
Save pfreixes/2b214ef3b8fc96f62825 to your computer and use it in GitHub Desktop.
Get benefit of current BTree implemenation of indexes in Mongodb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.test.find().count() | |
13 | |
> db.test.find() | |
{ "_id" : "01-02" } | |
{ "_id" : "01-01" } | |
{ "_id" : "01-03" } | |
{ "_id" : "02-01" } | |
{ "_id" : "02-02" } | |
{ "_id" : "02-03" } | |
{ "_id" : "03-01" } | |
{ "_id" : "03-02" } | |
{ "_id" : "03-03" } | |
{ "_id" : "03-04" } | |
{ "_id" : "03-05" } | |
{ "_id" : "03-06" } | |
{ "_id" : "01-04" } | |
> db.test.find({_id: /^02-/}).count() | |
3 | |
> db.test.find({_id: /^02-/}).explain() | |
{ | |
"cursor" : "BtreeCursor _id_ multi", | |
"nscanned" : 4, | |
"nscannedObjects" : 3, | |
"n" : 3, | |
"millis" : 0, | |
"nYields" : 0, | |
"nChunkSkips" : 0, | |
"isMultiKey" : false, | |
"indexOnly" : false, | |
"indexBounds" : { | |
"_id" : [ | |
[ | |
"02-", | |
"02." | |
], | |
[ | |
/^02-/, | |
/^02-/ | |
] | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment