首页 > 解决方案 > Mongodb 带索引的排序性能

问题描述

带/不带索引的 MongoDb 排序性能我有 500k 测试文件:

_id:5d5e5eb7f6ac46d3b0d88243
startDate:2019-08-23 13:08:34.377       (Date type)
duration:315532
_class:"Inviter Record"

我有简单的 startDate 索引(ASC)按查询{startDate: 1}性能(使用解释)和索引对我的文档进行排序:

执行时间Millis:977

没有:

执行时间Millis:356

我期待相反的结果

标签: mongodbperformancesortingindexing

解决方案


我搞砸了(使用没有索引的 500k 文档排序我实际上得到了 300+- milisec,但我也得到了 executionStatus: false 错误,比如你不能在 RAM 中保存超过 32mb 的数据,请使用索引


推荐阅读