查询优化

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.
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.

1.建立索引后的查询效率大大提升,但是索引查询的数量如果超过50%,意味着遍历更有优势。
2.索引增加会影响insert和update性能。

user有索引,扫描文档数为689,时间1ms
user无索引,全集合扫描,耗时61ms
voice_play有索引,扫描文档数1025,耗时2ms
voice_play无索引,全表扫描,耗时560ms
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容