搜索巨大的列表 [英] Searching huge Lists
本文介绍了搜索巨大的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是2,000,000件物品的清单,我不得不搜索个别物品。这花了我5分钟+。目前使用此代码:
列表< MyType> results = GetList();
MyType item = results.Find(item = > item.name == test);
显然这种速度是不可接受的,我只是想知道我能做些什么来改善这个。
存储/搜索这些数据的最佳方法是什么?
谢谢
Carl
解决方案
将其更改为每个循环的a。在速度测试中我做了LINQ总是最慢的。
foreach (MyType item in results){
if ( string 。比较(item.name, test, true )== 0 ){
// 做点什么。
}
}
我认为这取决于很多因素...
有几种方法可以提高LINQ查询性能 [ ^
Hi,
I am using a list of 2,000,000 items and i am having to search it for individual items. This is taking me 5 minutes+. Currently using this Code:
List<MyType> results = GetList();
MyType item = results.Find(item => item.name == "test");
Obviously this speed is unacceptable, I am just wondering what i can do to improve this.
What would be the best way to store/search this data?
Thanks
Carl
解决方案
Change it to a for each loop. In the speed test I have done LINQ was always the slowest by a large margin.
foreach (MyType item in results) { if (string.Compare(item.name, "test", true) == 0) { //Do Something. } }
I believe it depends on many factors...
There are few ways to Increase LINQ Query Performance[^]
这篇关于搜索巨大的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文