Debasish Mukherjee wrote:I have a very large list(Array List) of objects - approximately 50,000 to 60,000 instances of a particular class (which in turn has approximately 9-10 instance variables including Lists, Hash Map).
I need to filter this list as per user request based on 3 parameters.
This list is the life of my application - I need it be available for usage throughout the lifetime of my application. Also keeping the performance standard in mind - I can not afford to hit Database repeatedly. Is there any way so that i can cache this list in an effective manner? I am not permitted to alter the DB schema.
First: If your list/table contains 50-60,000 rows, I highly doubt that database access is going to be that much of an overhead.
Second: It's also highly likely that your database can sort and filter that list far quicker than you will ever do, because
that's what they're designed to do.
The only thing that caching the List
might do is to reduce network traffic between the db and your app; however, there are several other ways of doing that, and I'd want to be absolutely sure that I was solving an
actual problem - not a "perceived" one - before I wrote any extra caching layer.
And the ONLY way to prove that is with metrics.
W.A. Wulf wrote:More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason — including blind stupidity.
Winston