首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何提高蒙古族文献检索性能

如何提高蒙古族文献检索性能
EN

Stack Overflow用户
提问于 2017-09-23 13:59:38
回答 2查看 50关注 0票数 0

我正在从Mongo数据库中检索文档,并将它们复制到内部存储。我发现检索和存储这些文档需要超过几秒钟的时间。我能做些什么来提高成绩吗?一些集合有1000多个文档。这是我所拥有的(用vb.net写的)

代码语言:javascript
复制
' get the documents from collection "reqitems" and put them in "collection"
Dim collection As IFindFluent(Of BsonDocument, BsonDocument) = _
                            reqitems.Find(Builders(Of BsonDocument).Filter.Empty)
ReDim model.ReqItems(TotalCollection.ToList.Count)  ' storage for the processed documents
For Each item As BsonDocument In TotalCollection.ToList()  
  ' note: given a string a=x, "GetRHS" returns x 
  Dim parentuid As String = GetRHS(item.GetElement("parentuid").ToString)  
  Dim nodename As String = GetRHS(item.GetElement("nodename").ToString) 
  ' .... about a dozen of these elements
  ' .... process the elements and copy them to locations in model.ReqItems
next
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-10-03 19:13:14

增加指数并没有多大帮助。减慢速度的是每次访问文档中的元素(GetRHS在已发布的代码中)。因此,作为修正,我将文档转换为字符串,然后解析关键字值对的字符串。希望我所发现的能帮助那些有同样问题的人

票数 0
EN

Stack Overflow用户

发布于 2017-09-23 14:18:27

如果没有添加索引,可以将索引添加到集合中。请参阅:https://docs.mongodb.com/manual/indexes/

另外,我建议使用执行状态来运行特定的Mongodb查询。示例:db.mycollection.find().explain("executionStats");,它将为您提供有关查询性能的更多统计信息。https://docs.mongodb.com/manual/reference/explain-results/#executionstats

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46380372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档