Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongodb 溢出排序阶段缓冲数据使用情况_Mongodb_Sorting_Indexing - Fatal编程技术网

Mongodb 溢出排序阶段缓冲数据使用情况

Mongodb 溢出排序阶段缓冲数据使用情况,mongodb,sorting,indexing,Mongodb,Sorting,Indexing,我们有一个mongoDB 2.6.4副本集正在运行,正在尝试诊断此行为。我们得到了运行程序错误:溢出排序阶段缓冲数据使用33598393字节超过了33554432字节的内部限制,而我们预期不会。该集合有数百万条记录,并且有一个复合索引,其中包含正在排序的键。例如 索引看起来像这样 { from: 1, time : -1, otherA : 1, otherB : 1} 我们的发现是 find.collection({ from : { $in : ["a", "b"] }, time :

我们有一个mongoDB 2.6.4副本集正在运行,正在尝试诊断此行为。我们得到了
运行程序错误:溢出排序阶段缓冲数据使用33598393字节超过了33554432字节的内部限制,而我们预期不会。该集合有数百万条记录,并且有一个复合索引,其中包含正在排序的键。例如

索引看起来像这样

{ from: 1, time : -1, otherA : 1, otherB : 1}
我们的发现是

 find.collection({ from : { $in : ["a", "b"] }, time : { $gte : timestamp }, 
       otherA : {$in:[...]}, otherB : {$in:[...]}})
       .sort( time : -1 )   
mongoDB类似(子句)此查询如下:

{ from : a }, { time : { $gte : timestamp }, ... }
{ from : b }, { time : { $gte : timestamp }, ... }

在解释每个阶段的报告中,scanander:false,这意味着索引用于返回结果。这一切看起来都很好,但是mongoDB客户端得到了运行程序错误:溢出排序阶段缓冲数据使用错误。这似乎意味着排序是在内存中完成的。这是因为它正在执行内存中的合并类子句吗?还是有其他原因导致出现此错误?

我也面临同样的内存溢出问题。 我正在使用PHP和MongoDB来处理文档。 当我访问一个可能有大量文档的集合时,它抛出了一个错误。 根据下面的链接,它一次只能对32MB的数据进行排序。

根据MongoDocs中关于排序的描述, 我使用PHP而不是Mongo的sort()方法对从MongoCursor对象转换的数组进行排序

希望对你有帮助。
谢谢。

您能发布查询的完整解释吗?也许mongo无法合并已排序的并行部分结果。如果您只查询{from:“a”}和{from:“b”},这些是否有效?一种解决方法是在mongo之外手动合并。