gpt4 book ai didi

c# - MongoCursor 转换为 List 非常慢

转载 作者:可可西里 更新时间:2023-11-01 10:43:55 26 4
gpt4 key购买 nike

 MongoCollection<BsonDocument> collection = db.GetCollection("TestCollection");
MongoCursor<BsonDocument> cursor = collection.FindAll();
List<BsonDocument> list = cursor.toList();

这执行起来很慢。MongoCursor 转换为 List 非常慢,但是如果我使用以下代码:

MongoCollection<T> collection = db.GetCollection<T>("TestCollection");
MongoCursor<T> cursor = collection.findAll();
List<T> entities = cursor.toList();

上面的代码要快得多。为什么 MongoCursor 转换为 List 这么慢?我想使用 BsonDocument。我该如何解决这个问题?

最佳答案

驱动程序 1.8.0 ~ 1.8.2 存在错误。我们几天前遇到了同样的问题,并在 MongoDb JIRA 中报告了 CSHARP-822 .升级到 1.8.3+ 应该可以解决这个问题。

关于c# - MongoCursor<BsonDocument> 转换为 List 非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21412729/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com