Skip to content

Instantly share code, notes, and snippets.

@sheki
Created October 31, 2014 00:51
Show Gist options
  • Select an option

  • Save sheki/b47180a562975993a48e to your computer and use it in GitHub Desktop.

Select an option

Save sheki/b47180a562975993a48e to your computer and use it in GitHub Desktop.
nscanned_mongos
db['collection_name'].find({
$maxScan:500000,
$explain:true,
$query:{
"$and":[
{
"$or":[
{"_id":"NOvRVdV0ru"},
{"deviceIds":"id123"}
]
},
{
"_id":{
"$nin":["e8tFeJW797"]
}
}
],
"permission":{"$in":[null,"*"]}
}
})
{
"server": "db126:27017",
"allPlans": [
{
"indexBounds": {
"permission": [
[ null, null ],
[ "*", "*" ]
]
},
"nscanned": 500001,
"nscannedObjects": 500000,
"n": 0,
"cursor": "BtreeCursor permission_1 multi"
}
],
"indexBounds": {
"permission": [
[ null, null ],
[ "*", "*" ]
]
},
"millis": 15339,
"nChunkSkips": 0,
"nYields": 737,
"indexOnly": false,
"cursor": "BtreeCursor permission_1 multi",
"isMultiKey": false,
"n": 0,
"nscannedObjects": 500000,
"nscanned": 500001,
"nscannedObjectsAllPlans": 500000,
"nscannedAllPlans": 500001,
"scanAndOrder": false
}
db['collection_name'].find({
$maxScan:500000,
$explain:true,
$query:{
"$and":[
{
"$or":[
{"_id":"NOvRVdV0ru"},
{"deviceIds":"id123"}
]
},
{"_id":{"$nin":["e8tFeJW797"]}},
{"permission":{"$in":[null,"*"]}}
]
}
})
{
"server": "db126:27017",
"allPlans": [
{
"indexBounds": {
"permission": [
[ null, null ],
[ "*", "*" ]
]
},
"nscanned": 500001,
"nscannedObjects": 500000,
"n": 0,
"cursor": "BtreeCursor permission_1 multi"
}
],
"indexBounds": {
"permission": [
[ null, null ],
[ "*", "*" ]
]
},
"millis": 13665,
"nChunkSkips": 0,
"nYields": 648,
"indexOnly": false,
"cursor": "BtreeCursor permission_1 multi",
"isMultiKey": false,
"n": 0,
"nscannedObjects": 500000,
"nscanned": 500001,
"nscannedObjectsAllPlans": 500000,
"nscannedAllPlans": 500001,
"scanAndOrder": false
}
==GOOD CASE==
db['collection_name'].find({
$maxScan:500000,
$explain:true,
$query:{
"$or":[
{"_id":"NOvRVdV0ru","deviceIds":"id123"}
],
"_id":{"$nin":["e8tFeJW797"]},
"permission":{"$in":[null,"*"]}
}
})
{
"server": "db007:27017",
"allPlans": [
{
"indexBounds": {
"_id": [
[ "NOvRVdV0ru", "NOvRVdV0ru" ]
]
},
"nscanned": 1,
"nscannedObjects": 1,
"n": 1,
"cursor": "BtreeCursor _id_"
},
{
"indexBounds": {
"deviceIds": [
[ "id123", "id123" ]
]
},
"nscanned": 1,
"nscannedObjects": 1,
"n": 1,
"cursor": "BtreeCursor deviceIds_1"
},
{
"indexBounds": {
"permission": [
[ null, null ],
[ "*", "*" ]
]
},
"nscanned": 1,
"nscannedObjects": 1,
"n": 0,
"cursor": "BtreeCursor permission_1 multi"
},
{
"indexBounds": {},
"nscanned": 1,
"nscannedObjects": 1,
"n": 0,
"cursor": "BasicCursor"
}
],
"indexBounds": {
"_id": [
[ "NOvRVdV0ru", "NOvRVdV0ru" ]
]
},
"millis": 0,
"nChunkSkips": 0,
"nYields": 0,
"indexOnly": false,
"cursor": "BtreeCursor _id_",
"isMultiKey": false,
"n": 1,
"nscannedObjects": 1,
"nscanned": 1,
"nscannedObjectsAllPlans": 4,
"nscannedAllPlans": 4,
"scanAndOrder": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment