|
-
Jan 17th, 2013, 05:00 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] DataTable.AddRow is very slow
I am looping through around 500,000 records to compile a report in a nightly 'batch' process. In the old Visual Basic 6 app this process took less than 3 minutes. However I was finding that the C# way I am using was taking 50-60 minutes.
The process is looping through some purchase history, matching, updating and adding it to a DataTable that will later be read and added to the database. This second DataTable ends up with around 12,000 unique records.
I believe this is because when calling DataTable.AddRow(DataRow) it is updating notifications, doing index maintenance, and constraints. If I would have looked closer at the MSDN docs for DataTable I would have noticed this:
http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx
Since I changed to using DataTable.BeginLoadData and DataTable.EndLoadData the process is now sub 2 minutes.
Any comments on another approach to this process are appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|