Skip to content

Instantly share code, notes, and snippets.

@fabioperrella
Created April 3, 2012 12:02
Show Gist options
  • Save fabioperrella/2291445 to your computer and use it in GitHub Desktop.
Save fabioperrella/2291445 to your computer and use it in GitHub Desktop.
mongodb criando indice para custom field
> db.contacts.find({"custom_fields.gender":"fem"}).explain()
{
"cursor" : "BasicCursor",
"nscanned" : 1002,
"nscannedObjects" : 1002,
"n" : 244,
"indexBounds" : {
}
}
> db.contacts.ensureIndex({"custom_fields.gender": 1})
> db.contacts.find({"custom_fields.gender":"fem"}).explain()
{
"cursor" : "BtreeCursor custom_fields.gender_1",
"nscanned" : 482,
"nscannedObjects" : 482,
"n" : 244,
"indexBounds" : {
"custom_fields.gender" : [
[
"fem",
"fem"
]
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment