更新内存数据表中的单元格
好的,到目前为止的故事是我有一个数据表,大约 10,000 行左右。每行大约 150 列。此数据表中或多或少有 150.000 个单元格。我所有的更新都工作正常 但更新速度很慢。 我需要遍历过程列表,然后根据过程更新表中的单元格。当我完成更新后,大约 75% - 80% 的所有单元格都会发生变化。 我正在使用分配给 INT 值的主键索引对表进行搜索。
datatable.rows.find() 似乎有点快 datatable.select(表达式)几乎相同但差别不大。
有什么想法可以加快这一速度吗?更换 80,000 - 120,000 个电池可能需要几分钟的时间。
任何想法都会非常感谢。
Ok, the story so far is i have a datatable, about 10,000 lines or so. and about 150 columns per row. ao more or less 150.000 cells in this datatable. i have all updateing working fine
but the updating is slow.
I need to iterate through a list of porcedures then update cells in the table depending on the procedure. when i am completle finished updating about 75% - 80% of all the cells will have changed.
I am using a search on the table using a primary key index assigened to an INT value.
datatable.rows.find() seems a a little quicker
datatable.select ( expression ) almost the same but little difference.
Is there any ideas who may speed this up. uppon changing 80,000 - 120,000 cells it can take minutes.
anyideas would be great thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ASP.Net Pro 杂志 2005 年 3 月号中的一项研究比较了涉及
DataTables
、DataViews
和DataReaders
的各种方法。他们的发现是,最快的方法取决于所涉及的记录数量。对于 50 条或更少的记录,迄今为止最快的搜索方法是
DataTable 的 DataRowCollection
上的For..Next
循环。DataRowCollection.Find
遵循了这种方法。使用DataReader
、使用DataView.RowFilter
重新检索数据要慢很多倍,最糟糕的是使用DataTable.Select
。对于 500 - 5,000 条记录,最快的搜索是使用
DataRowCollection.Find
,其次是DataTable.Select
。到目前为止,此范围的记录中最差的是DataView.RowFilter
和DataView.FindRows
。对于50,000 条记录,最快的搜索是使用
DataRowCollection.Find 完成的。
紧随其后的是使用DataReader
重新检索记录。迄今为止,此类别中最差的是 DataView.RowFilter 和 DataView.FindRows。A study in the March 2005 issue of ASP.Net Pro magazine compared various approaches involving
DataTables
,DataViews
andDataReaders
. Their findings were that the fastest approach depended upon the number of records involved.For 50 records or less, by far the fastest search method was a
For..Next
loop on theDataTable's DataRowCollection
. That approach was followed byDataRowCollection.Find
. Many times slower were re-retrieving the data with aDataReader
, usingDataView.RowFilter
, and worst of all usingDataTable.Select
.For 500 - 5,000 records, the fastest search was with
DataRowCollection.Find
, followed closely byDataTable.Select
. The worst by far for this range of records wereDataView.RowFilter
andDataView.FindRows
.For 50,000 records, the fastest search was accomplished with
DataRowCollection.Find.
In a close second place was re-retrieving the records with aDataReader
. The worst by far for this category wereDataView.RowFilter
andDataView.FindRows.