【问题标题】:MongoDB - too much data for sort() with no index error using C# driver on a small record setMongoDB - sort() 数据过多,在小记录集上使用 C# 驱动程序没有索引错误
【发布时间】:2013-11-18 08:07:04
【问题描述】:

我看到其他人遇到过这个问题,但没有明确的答案。就我而言,我使用的是 C# 驱动程序。我的排序是这样的:

 cursor.SetSortOrder(SortBy.Ascending("Location", "BusinessLine", "Manager", "TeamLead", "AgentName", "EventDate"));

收集了 32,201 条记录,运行良好。除此之外,我得到这个错误。我已经在任何和我的排序变量上尝试了索引,但没有任何改变结果。有什么想法吗?

【问题讨论】:

标签: c# mongodb sorting


【解决方案1】:

问题在于批量大小。在遍历游标之前,您必须设置批量大小。在这种情况下,我将其设置为 cursor.BatchSize = 30000;而且效果很好。

【讨论】:

  • 这意味着您将返回 30,000 条记录,如果它们适合 16meg 的 RAM,否则您将返回下一个最接近的东西。 Batchsize 可能是您不想要的
猜你喜欢
  • 2011-05-22
  • 2013-07-14
  • 1970-01-01
  • 2018-12-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-11
  • 2017-04-23
相关资源
最近更新 更多