Unless it is required to make heavy calculations to fill object's content, creation is faster. Note that retrieving from database also includes object creation, and access to database itself requires a lot of processor's cycles.
Alexei Kaigorodov wrote:Note that retrieving from database also includes object creation, and access to database itself requires a lot of processor's cycles.
Although I agree with you in general, it's worth noting that the whole reason that databases exist is to persist and retrieve data; so, while for an individual object what you say is right, if Paras needs to store lots of objects, a database (NOT a file) is probably the way to go.
@Paras: Either way, serialization, while convenient, is extremely slow. It's more often used with Streams to pass entire objects across a network than as a primary persistence mechanism. And, unless you're dealing with very small amounts of data, a database is probably better than using files - in fact, with a 'wrapped' db like JavaDB it may even be better for individual objects too.
Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Joined: May 22, 2012
Well, i only know how to store objects in a file. Let me know how to do the same in database.
Also, another performance related question:
Is it better to import whole packages or just the classes we need to use.
I am making quite a big project and such minute things are affecting my performance (i think)
fred rosenberger wrote:
So having a lot of imports may slow down your compile phase, it will have ZERO impact on your run-time performance.
(at least, this is what I have read many, many times).
You can prepare a test case: two versions of a class, one with fully qualified class names, the other the same but with imports,
and then you can disassemble the resulting classes to verify they are essentially identical.