Mongodb $3.4 Write Operation Performance
Mongodb $3.4 Optimize Query Performance
Each index on a collection adds some amount of overhead to the performance of write operations.【查询优化】1.建立索引后的查询效率大大提升,但是索引查询的数量如果超过50%,意味着遍历更有优势。
For each insert or delete write operation on a collection, MongoDB either inserts or removes the corresponding document keys from each index in the target collection. An update operation may result in updates to a subset of indexes on the collection, depending on the keys affected by the update.
2.索引增加会影响insert和update性能。
文章图片
user有索引,扫描文档数为689,时间1ms
文章图片
user无索引,全集合扫描,耗时61ms
文章图片
voice_play有索引,扫描文档数1025,耗时2ms
文章图片
voice_play无索引,全表扫描,耗时560ms