Skip to content

Instantly share code, notes, and snippets.

@charity
Last active December 29, 2015 03:18
Show Gist options
  • Save charity/7606304 to your computer and use it in GitHub Desktop.
Save charity/7606304 to your computer and use it in GitHub Desktop.
mongodata3:SECONDARY> c.find({ $query: {ppoi_0: { $nearSphere: [ -74.5287, 40.1301 ], $maxDistance: 0.02601798524805497 } , deviceType: "ios", channels: { $in: [ "featured_coupons", "special_sales" ] }, appVersion: { $in: [ "3.0", "3.0.1", "3.1", "3.5" ] } }}).explain()
{
"cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : 0,
"nscannedObjects" : 6484024,
"nscanned" : 6484024,
"nscannedObjectsAllPlans" : 6484024,
"nscannedAllPlans" : 6484024,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 278,
"nChunkSkips" : 0,
"millis" : 38100,
"indexBounds" : {
},
"server" : "db37:27017"
}
# when I remove $query it uses the geo index
mongodata3:SECONDARY> c.find( {ppoi_0: { $nearSphere: [ -74.5287, 40.1301 ], $maxDistance: 0.02601798524805497 } , deviceType: "ios", channels: { $in: [ "featured_coupons", "special_sales" ] }, appVersion: { $in: [ "3.0", "3.0.1", "3.1", "3.5" ] } }).explain()
{
"cursor" : "GeoSearchCursor",
"isMultiKey" : false,
"n" : 100,
"nscannedObjects" : 100,
"nscanned" : 100,
"nscannedObjectsAllPlans" : 100,
"nscannedAllPlans" : 100,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
},
"server" : "db37:27017"
}
# added a hint for it to use the geo index, still doesn't work
mongodata3:SECONDARY> c.find({ $query: {ppoi_0: { $nearSphere: [ -74.5287, 40.1301 ], $maxDistance: 0.02601798524805497 } , deviceType: "ios", channels: { $in: [ "featured_coupons", "special_sales" ] }, appVersion: { $in: [ "3.0", "3.0.1", "3.1", "3.5" ] } }, $hint: {ppoi_0: 1}}).explain()
{
"cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : 0,
"nscannedObjects" : 6484255,
"nscanned" : 6484255,
"nscannedObjectsAllPlans" : 6484255,
"nscannedAllPlans" : 6484255,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 555,
"nChunkSkips" : 0,
"millis" : 49386,
"indexBounds" : {
},
"server" : "db37:27017"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment