我正在获取
Error: too much data for sort() with no index
按日期升序排序时。仅当记录数超过 9 时,我才会出现此异常。有人可以告诉我我做错了什么吗?或者有什么解决办法吗?
我的排序语法是:
image.find({reviewed:true },null,{sort:{"submittedDate":-1}}, function (err, images){});
最佳答案
根据此处的文档:http://www.mongodb.org/display/DOCS/Indexes#Indexes-Using {{sort%28%29}}没有索引
You may use sort() to return data in order without an index if the data set to be returned is small (less than 32 megabytes in version 2.0, or less than four megabytes in version 1.8 and earlier). For these cases it is best to use limit() and sort() together.
这 9 个文档实际上可能大于 32 兆字节吗?或者,像以前的版本一样,超过 4 兆字节?
关于node.js - 按日期排序 Mongoose 抛出错误记录超过 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13341218/