Derby is really an in-memory database

Up to Derby, the in-memory database mode wasn’t a real one because data was stored into files onto your disk. The new supports a real in-memory mode were data is only stored in memory, with no files being created. As stated in the new features page : Initial implementation of a storage engine for Derby where all data is kept in memory. There is no documentation for this feature. This functionality itself is not yet fully implemented, but users are welcome to experiment with it. So I did test it.

First of all, if you are using Maven, you will be disappointed to know that the release is not in the default Apache repository. You need to add the following repository to your pom.xml :

  <id>Apache Repo</id>
  <name>Apache repository for Derby</name>

Then, the JDBC URL has to be changed from jdbc:derby:chapter02DB;create=true to jdbc:derby:memory:chapter02DB;create=true.

As a little benchmark, I have an application with 25 test cases using in-memory storage with Derby It took 5 minutes and 53 seconds to run all the tests. With the new it only took 21 seconds. Not bad.

One thought on “Derby is really an in-memory database

  1. hsqldb in in-memory mode is pretty cool for development too. I use it even for my blog (persistence mode of course) running on fairly old low mem hardware. But derby has the out-of-the-box advantage since it is included in the JDK as JavaDB 😉

Leave a Reply