Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,
I have one Sql Table which is having two columns Rowid – int, XMLRecord – XML which contains 1000000 records in it. I have to read that record & write that in to text file.
I have written program to do that but it is taking near about 25minute to do that how can I increase the performance of this process
I have methods like this

C#
ReadXML()
{
  Sql XML to get data from Sql table
  XMLReader to read node of xml 
  This is returning Entity object
}

WriteXML (Entity object)
{
  Here I am using some more variable & objects
  I am using some looping to get data from Entity object
  StreamWritter to write into file
}

In this case ReadXML () method is taking only 3 minutes and WriteXML (Entity object) is taking more time.

How can I increase performance of this program? Which care should I take while using loop, StreamWritter and in loop I am creating some local object it is necessary to destroy that . Which method should be the best to dispose those objects?
Please assist me….

-Dattatrya Moin
Posted
Updated 29-Mar-12 8:07am
v3

Take a look at the following link below on parallel loops.
http://msdn.microsoft.com/en-us/library/dd460720.aspx[^]

And async programming.
http://msdn.microsoft.com/en-us/library/2e08f6yc%28v=vs.71%29.aspx[^]
 
Share this answer
 
Comments
Dattatrya Moin 11 29-Mar-12 22:05pm    
Thank you for your response, I will try that Parallel.ForEach Loop concept & I am using Background thread Asynchronous Calling.

Thanks.
Use a background thread to do the long running process.
 
Share this answer
 
Comments
Dattatrya Moin 11 29-Mar-12 22:03pm    
Thank you for you response but I am using background Thread in this program & Asynchronous calling that's why it is writing in 25 minute.
[no name] 29-Mar-12 22:06pm    
At the risk of sounding like an idiot but you do know that writing that many records to disk is going to be ssssssslllllllooooooooowwwwwww. Your problem might not be software choking the life out of your app but the hardware is going to be the limiting factor....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900