aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Reading records into memory or parsing db on demand? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Reading records into memory or parsing db on demand?" Watch "Reading records into memory or parsing db on demand?" New topic
Author

Reading records into memory or parsing db on demand?

James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
Hi guys,

I have a question about the db file records, do you think it is better to read in the records of the db into an array in memory at the start of the program, or simply create a stream to the file and parse through the file for each find/insert/... request.

Obviously less memory is required to parse the db on demand, but this is also a lot slower and more complex way of doing it. One thing is that the db could grow in the future so reading it into memory could cause problems (assuming this was a real world project).

Does anyone have any views on this issue? With regards to the scope of this assignment, which would be considered best?

Thanx for any help.

Jarvis


James<br />SCJP 1.4 - 92%<br />SCJD - 93%<br />SCWCD 1.4 - 95%<br />SCBCD 1.3 - 100%<br />SCEA - 92%
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi Jarvis:
There are many discussions about this topic in the past few weeks, and there are many intresting opinions.
IMO I prefere to access the data on demand directly from the database. it is slower, but speed is not everything, unless you are doing real time application, like banking. To me, scalability and extesibility is more important. Sure, it takes more programming work, but is is bullet broof solution for extinsible database application. Bringing the data to the memory, IMO is risky. One never know how large the data file is, or how larg the database can grow to. More over, one can never know how large the memory allocated to the JVM at a particular host. All these reasons put so much restirections on how the application can run.
There are many people prefere to bring the database to the memory. You have to use you own judgment, and what you are comfortible with.


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
Thanx for your view, apreciated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading records into memory or parsing db on demand?
 
Similar Threads
[NX: UrlyBird 1.3.2] Storing data in memory
NX:IOExceptions What to do?
Bodgitt and Scarper 2.2.1: Caching
B&S: Reading a deleted record - best way to handle this
Parsing and Storing HUGE XML files