Mongodb C# 查询排序超出了内存限制
Mongodb C# Query Sort exceeded memory limit of
我有 2 周的时间学习和使用 MongoDB,我正在使用 DataGridview 构建一个简单的 WinForm 应用程序。
一切正常,但我添加了超过 1.000.000 个文档,现在显示此错误:
MongoDB.Driver.MongoCommandException: 'Command aggregate failed: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in..'
我已经检查了整个周末 google 如何使用聚合 allowDiskUse:true 但它也不起作用。
谢谢。
public void ReadAllDocuments()
{
List<Clientes> list = collection.AsQueryable().OrderBy(q => q.Nombre).ToList();
dataGridView1.DataSource = list;
if (dataGridView1.Rows.Count > 0)
{
textBox1.Text = dataGridView1.Rows[0].Cells[0].Value.ToString();
textBox2.Text = dataGridView1.Rows[0].Cells[1].Value.ToString();
textBox3.Text = dataGridView1.Rows[0].Cells[2].Value.ToString();
}
}
你真的需要带走馆藏的所有文件吗?
您应该能够将聚合器选项传递给可查询对象。
collection.AsQueryable(new AggregateOptions { AllowDiskUse = true })
但是,通常情况下,排序超过文档限制表明您的查询不是最优的。您可能需要重新考虑您的数据库设计或查询,这样您就不必对这么大的数据集进行排序。
我有 2 周的时间学习和使用 MongoDB,我正在使用 DataGridview 构建一个简单的 WinForm 应用程序。
一切正常,但我添加了超过 1.000.000 个文档,现在显示此错误:
MongoDB.Driver.MongoCommandException: 'Command aggregate failed: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in..'
我已经检查了整个周末 google 如何使用聚合 allowDiskUse:true 但它也不起作用。
谢谢。
public void ReadAllDocuments()
{
List<Clientes> list = collection.AsQueryable().OrderBy(q => q.Nombre).ToList();
dataGridView1.DataSource = list;
if (dataGridView1.Rows.Count > 0)
{
textBox1.Text = dataGridView1.Rows[0].Cells[0].Value.ToString();
textBox2.Text = dataGridView1.Rows[0].Cells[1].Value.ToString();
textBox3.Text = dataGridView1.Rows[0].Cells[2].Value.ToString();
}
}
你真的需要带走馆藏的所有文件吗?
您应该能够将聚合器选项传递给可查询对象。
collection.AsQueryable(new AggregateOptions { AllowDiskUse = true })
但是,通常情况下,排序超过文档限制表明您的查询不是最优的。您可能需要重新考虑您的数据库设计或查询,这样您就不必对这么大的数据集进行排序。