MongoDB 查询优化
新手求大神指点: 业务所需这么复杂查询,1000w数据,查询忒慢,无法忍受. 下列查询条件怎么建索引,优化和改进;
{"other":{"column":{"label":1,"content":1},"distinct":{},"group":{},"order":{"_id":-1},"limit":10,"skip":0,"lastIndex":184},"where":{"school_id":"2","created_at":{"$gt":"1446900125240"},"class_id":{"$in":[“1”]},"label":"1","status":"0","$or":[{"visible_user_list":{"$in":[“1”]}},{"is_for_class":"1"},{"is_for_school":"1"}]}}
4 回复
@wangbinlml 你先从索引的角度看看问题吧。1000w感觉不多的。
mongodb 的版本也要注意一下,用 3.0,开启 wiredTiger 引擎会好很多。原来的引擎很渣。
sharding 略麻烦。