Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

improving prformance of c3 appl 1

Status
Not open for further replies.

developer155

Programmer
Joined
Jan 21, 2004
Messages
512
Location
US
Hi,
i am writing an app that reads from a large file (500K + records) processes data and writes to a db.
Now along the way I query the db and write to an errro file for all records (check data and write errors). The app is slow and I am trying to improve that.
NowI open db connection once (in the beginning of app) as well as StreamWriter object to write to error file. My question is is that a correct technique or is it better to open and close db connection and streamwriter every time i need to query the db or write to a file?
thanks!
 
I would open it only once.

All file writing operations take some time. Inserting into a DB is usually faster than writing to a file because the DB takes care of storing the information.

When you write to a file, do you flush the buffer every time? You might want to store 100 lines and then flush the buffer to the file and that should speed things up a little bit for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top