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.