如何在C#.NET中执行170000条记录 [英] how to execute 170000 records in C#.NET

查看:40
本文介绍了如何在C#.NET中执行170000条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个巨大的要求,即我必须使用for循环执行170000次记录3次。



从第三方系统我将获得170000条记录。每条记录包含50列。



在我的系统中,我必须执行算法,我需要使用该输入更新500列,这里除了50个输入列我们还需要从表中获取一些其他值。



对于这些170000条记录,我必须执行3次,这意味着我必须在SQL数据库中更新510000条记录。要完成整个过程需要花费大量时间(小时数),但客户要求是4秒。





请帮助关于我们如何以更好的方式执行。



谢谢,

Codehub。

Hi All,

I have one huge requirement i.e. I have to execute 170000 records 3 times using for loop.

From 3rd party system i will get the 170000 records. Each record contain 50 columns.

In my system , i have to execute a alogorithm and i need to update the 500 columns using that input,here apart from 50 input columns we need to take some other values from tables as well.

For these 170000 records , i have to execute 3 times it means 510000 records i have to update in SQL database.To complete the entire process it is taking lot of time (means hours), but client requirement is 4 seconds.


Please help on this how we can execute in a better way.

Thanks,
Codehub.

推荐答案

您将问题标记为C#,因此...我建议使用 SqlBulkCopy类 [ ^ ]。使用 WriteToServer方法 [ ^ ]和特殊标志 [ ^ ]使您可以编写修改数据。



您可以使用计算列来计算某些值。请参阅:创建表达式列 [ ^ ] + DataTable.Compute方法 [ ^ ]。



我希望使用这种方法执行的时间可能只有几分钟......
You tag the question as C#, so... i'd suggest to use SqlBulkCopy class[^]. Using WriteToServer method[^] together with special flag[^] enables you to write modified data.

You can use compute column to calculate some values. Please see: Creating Expression Columns[^] + DataTable.Compute method[^].

I hope that using this method the time of execution would be few minutes...


这篇关于如何在C#.NET中执行170000条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆