Does this still hold true?
Hi everyone,
Back in the "old" days, people always told me, manipulate files as little as possible! It is expensive and will slow down the application! Is this still true?
One of the things I'm working on right now involves a lot of saving, but I have a choice between saving to disk, or saving to a database (which, if you ask me, eventually will end up being saved to disk anyways). Am I right to assume that the "cost" to use either method is more or less the same, with the database incurring a bit more overhead because it needs to figure out where to write the data?
Or am I just archaic in thinking that this is still an issue?
Thanks,
April
Re: Does this still hold true?
It is true that writing/reading from the hard drive is much slower than writing/reading from memory or cache (even with the new solid state hard-disks). However, unless you are dealing with a large amount of data, or are sending reading/writing commands a huge number of times in a short period of time, modern computers are fast enough they can usually handle the read/writes without too much lag.
I know in Java that you can speed up file write times by using a BufferedWriter to encapsulate the FileWriter. In this way, Java is making a bunch of writes to memory, and then every now and then writes chunks of data consecutively (I think when the buffer gets flushed), instead of FileWriter's method of writing to the hard disk every time a write command is given.
What kind of file manipulation did you have in mind?
Re: Does this still hold true?
I guess in essence, I'm trying to log a transaction system. They don't have to be 100% real time accurate (ie. if two people request for a resource at the same time, it's not important down to the milisecond which one was first), but keeping a log of these transactions in sequence is important. I'm expecting maybe 5000-10000 lines per user per four to five hour session, and maybe up to 20-50 concurrent users. I haven't decided whether to keep them separate for each user or have a separate file for each user, but there'll need to be daily archives, etc.