Derby vs PostgreSql Performance Comparison

Austin picture Austin · Jan 26, 2010 · Viewed 10.4k times · Source

We are doing research right now on whether to switch our postgresql db to an embedded Derby db. Both would be using glassfish 3 for our data layer. Anybody have any opinions or knowledge that could help us decide?

Thanks!

edit: we are writing some performance tests ourselves right now. Looking for answers more based on experience / first hand knowledge

Answer

Dan picture Dan · Jun 12, 2013

I know I'm late to post an answer here, but I want to make sure nobody makes the mistake of using Derby over any production-quality database in the future. I apologize in advance for how negative this answer is - I'm trying to capture an entire engineering team's ill feelings in a brief Q&A answer.

Our experience using Derby in many small-ish customer deployments has led us to seriously doubt how useful it is for anything but test environments. Some problems we've had:

  • Deadlocks caused by lock escalations - this is the biggest one and happens to one customer about once every week or two
  • Interrupted I/Os cause Derby to fail outright on Solaris (may not be an issue on other platforms) - we had to build a shim to protect it from these failures
  • Can't handle complicated queries which MySQL/PostgreSQL would handle with ease
  • Buggy transaction log implementation caused a table corruption which required us to export the database and then re-import it (couldn't just drop the corrupted table), and we still lost the table in the process - thank goodness we had a backup
  • No LIMIT syntax
  • Low performance for complicated queries
  • Low performance for large datasets

Due to the fact that it's embedded, Derby is more of a competitor to SQLite than it is to PostgreSQL, which is an extremely mature production-quality database which is used to store multi-petabyte datasets by some of the largest websites in the world. If you want to be ready for growth and don't want to get caught debugging someone else's database code, I would recommend not using Derby. I don't have any experience with SQLite, but I can't imagine it being much less reliable than Derby has been for us and still being as popular as it is.

In fact, we're in the process of porting to PostgreSQL now.