I need to use an embedded database in my java application that will be run in a Linux device. The application uses Hibernate and derby database. This is not a Android application. Due to slow performance of the database, we are looking for a better embedded database framework. Looking at all the options, H2 seems to be better than SQLite as there is no cross-compilation involved and no JNI interface to build. So, why isn't there a more usage of H2. Are there any drawbacks or issues that I am not aware of.
Comparing the normalized speed of Hibernate with SQLite embedded database (0.080) to the normalized speed of Hibernate with H2 database server (6.7) reveals that in that case, Hibernate with H2 server is 83.8 times faster than Hibernate with SQLite embedded.
SQLite Database is an open-source database provided in Android which is used to store data inside the user's device in the form of a Text file. We can perform so many operations on this data such as adding new data, updating, reading, and deleting this data.
SQLite works great as the database engine for most low to medium traffic websites (which is to say, most websites). The amount of web traffic that SQLite can handle depends on how heavily the website uses its database. Generally speaking, any site that gets fewer than 100K hits/day should work fine with SQLite.
sqlite packages offer a higher-performance alternative where source compatibility is not an issue. There is no file parsing and generating code to write and debug. Content can be accessed and updated using powerful SQL queries, greatly reducing the complexity of the application code.
I recently switched from H2 to SQLite because of database corruptions in the H2 mv store.
If the application is not shutdown properly, or in case of unexpected reboots, the H2 database stored on a file using the MV store (the default) can get corrupt, and you can't restore data.
SQLite is much more robust to corruption.
Speed wise H2 was much faster in my case. With SQLite transactions are particularly costly, so you should prefer doing bulk operations within transactions or via batches.
As for cross compilation, you can use the jdbc driver from xerial which ships with all the native binaries precompile : https://github.com/xerial/sqlite-jdbc
The SQLite library is implemented in C, so it indeed needs (cross-)compilation and a JNI interface. However, SQLite is so widely used that it is likely that the SQLite interface already exists (as part of your language's runtime, or as a JDBC driver), and that using it is simpler than explicitly adding H2 to your project. (This might not actually be true in your specific environment.)
If you're looking to speed up your application, you have to measure yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With