Skip to content

Instantly share code, notes, and snippets.

@skippy
Created March 5, 2011 07:58
Show Gist options
  • Save skippy/856216 to your computer and use it in GitHub Desktop.
Save skippy/856216 to your computer and use it in GitHub Desktop.
> db.data_points.find({ sensor_id: 247, faulty: { $ne: true }, orig_relative_time: { $lte: new Date(1299305991280) }, deleted_at: { $exists: false } }).sort({ orig_relative_time: -1 }).limit(-1).explain()
{
"cursor" : "BtreeCursor orig_relative_time_-1_sensor_id_-1",
"nscanned" : 11859,
"nscannedObjects" : 11859,
"n" : 11859,
"millis" : 1896,
"indexBounds" : {
"orig_relative_time" : [
[
"Sat Mar 05 2011 06:19:51 GMT+0000 (UTC)",
"Thu Jan 01 1970 00:00:00 GMT+0000 (UTC)"
]
],
"sensor_id" : [
[
247,
247
]
]
}
}
> db.data_points.find({ sensor_id: 247, faulty: { $ne: true }, orig_relative_time: { $lte: new Date(1299305991280) }, deleted_at: { $exists: false } }).sort({ orig_relative_time: -1 }).limit(1).explain()
{
"cursor" : "BtreeCursor sensor_id_-1_orig_relative_time_-1",
"nscanned" : 1,
"nscannedObjects" : 1,
"n" : 1,
"millis" : 0,
"indexBounds" : {
"sensor_id" : [
[
247,
247
]
],
"orig_relative_time" : [
[
"Sat Mar 05 2011 06:19:51 GMT+0000 (UTC)",
"Thu Jan 01 1970 00:00:00 GMT+0000 (UTC)"
]
]
}
}
@skippy
Copy link
Author

skippy commented Mar 5, 2011

I should note that the millis in the first explain is very high...the DB was getting hammered then so I suspect that is what caused it to be slow. After it warmed up it settled down, but still fairly high, in the 80-150 range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment