10

I am not sure whether to use Java Collections or some in-memory DB (H2 or HSQLDB - they are probably the fastest). I need a good performance results - there will be hundreds of objects/rows, no JOIN or more complex queries would be performed.

I am really considering in-memory DB, because of limited size of java heap - the objects that I am working with may be quite large and also there will be a lot of them (hundreds as I mentioned)

do you think it is a good idea to use in-memory database for a large amount of data?

3
  • 2
    in modern terms, hundreds of objects aren't much. When you say that the objects will be big -- how big? Commented Feb 14, 2012 at 18:56
  • 3
    Hundreds of objects is laughable, even if each object has a hundred fields. Besides, the memory has got to come from somewhere, and a DB will likely add some overhead. Commented Feb 14, 2012 at 18:56
  • Well, hundreds ... that may be an overkill... simply - there can be a really lot of objects. Commented Feb 14, 2012 at 18:59

3 Answers 3

3

Hundreds of 10 KB objects is still only a few MB. Keep it simple is my suggestion. Hundreds of thousands of 1 KB objects will still easily fit into a 32-bit JVM.

I wouldn't use an in memory database until you are getting into the GBs of data. If you have hundreds of GB, your only option is to use a database of some sort.

Disclaimer: I use in memory databases and have even written one or two.

Sign up to request clarification or add additional context in comments.

Comments

3

Try to do it with collections. If you then realize a problem you can still swich. It is all a matter of abstracting the implementation so your algorithms do not expect one or the other. (Yet another "early-optimization is evil" rant)

Comments

2

As others have said, "hundreds" is really not a lot, and now it sounds like you are even saying potentially less than hundreds. ANd if the heap size is a problem you can Increase the JVM Heap Size

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.