Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Created October 26, 2012 13:07
Show Gist options
  • Save michaeltwofish/3958689 to your computer and use it in GitHub Desktop.
Save michaeltwofish/3958689 to your computer and use it in GitHub Desktop.
Slow query, extra field that the whole collection shares same value
> db.sittings.find({ "user.id" : "504fffe45c69233171000000", "status_id" : { "$in" : [ 1, 2 ] }, "app" : "schools", "metadata.client_id" : "4" }).explain()
{
"cursor" : "BtreeCursor user.id_1",
"nscanned" : 4,
"nscannedObjects" : 4,
"n" : 4,
"millis" : 686,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"user.id" : [
[
"504fffe45c69233171000000",
"504fffe45c69233171000000"
]
]
}
}
> db.sittings.find({ "user.id" : "504fffe45c69233171000000", "status_id" : { "$in" : [ 1, 2 ] }, "metadata.client_id" : "4" }).explain()
{
"cursor" : "BtreeCursor user.id_1",
"nscanned" : 4,
"nscannedObjects" : 4,
"n" : 4,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"user.id" : [
[
"504fffe45c69233171000000",
"504fffe45c69233171000000"
]
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment