I have the following query that is kind of like a reverse range lookup:
db.ip_ranges.find({ $and: [{ start_ip_num: { $lte: 1204135028 } }, { end_ip_num: { $gt: 1
After a ton of experimenting and researching, I came across this:
https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/IUwOzWsc0Sg
I'm able to get the query down around 200-300ms with this query, AND dropping all indexes (You have to drop all the indexes for this to work!!!):
db.ip_ranges.find({start_ip_num: {$lte: 1204135028}, end_ip_num: {$gt: 1204135028}}).limit(1)
Don't ask me why. I can't explain it. If you're interested, I was building the GeoIP database from MaxMind with MongoDB.