Compare with

Comparison of Hibernate with MySQL server vs OpenJPA with PostgreSQL server

Each of the following tables focuses on a specific database operation, where the last table presents average results comparison.

Speed comparison of JPA database persistence operations (normalized score, higher is better)

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Basic Person Test3.65.21.64.82.65.0
Element Collection Test1.62.80.722.21.12.5
Inheritance Test3.74.61.63.22.73.9
Indexing Test5.47.42.66.94.07.1
Graph (Binary Tree) Test1.50.981.20.811.40.89
Multithreading Test7.423.42.99.15.216.2
All Tests3.97.41.84.52.85.9

The results above show that in general OpenJPA with PostgreSQL server is more efficient than Hibernate with MySQL server in persisting JPA entity objects to the database. Comparing the normalized speed of Hibernate with MySQL database server (2.8) to the normalized speed of OpenJPA with PostgreSQL database server (5.9) reveals that in these tests, OpenJPA with PostgreSQL server is 2.1 times faster than Hibernate with MySQL server.

A large performance gap has been detected when using multithreading with small transaction size. Comparing the normalized speed of Hibernate with MySQL database server (7.4) to the normalized speed of OpenJPA with PostgreSQL database server (23.4) reveals that in that case, OpenJPA with PostgreSQL server is 3.2 times faster than Hibernate with MySQL server.

Speed comparison of JPA database retrieval operations (normalized score, higher is better)

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Basic Person Test3.05.811.016.17.010.9
Element Collection Test0.340.0131.28.70.794.4
Inheritance Test1.35.214.517.67.911.4
Indexing Test2.54.812.818.77.611.8
Graph (Binary Tree) Test0.550.270.710.350.630.31
Multithreading Test0.2311.913.823.37.017.6
All Tests1.34.79.014.15.29.4

The results above show that in general OpenJPA with PostgreSQL server is more efficient than Hibernate with MySQL server in retrieving JPA entity objects from the database.

A huge performance gap has been detected when using multithreading with small retrieval size. Comparing the normalized speed of Hibernate with MySQL database server (0.23) to the normalized speed of OpenJPA with PostgreSQL database server (11.9) reveals that in that case, OpenJPA with PostgreSQL server is 51.7 times faster than Hibernate with MySQL server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.013) to the normalized speed of Hibernate with MySQL database server (0.34) reveals that in that case, OpenJPA with PostgreSQL server is 26.2 times slower than Hibernate with MySQL server.

Speed comparison of JPA database query operations (normalized score, higher is better)

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Basic Person Test10.0failed2.0failed6.0failed
Element Collection Test6.7failed0.53failed3.6failed
Inheritance Test2.8failed1.6failed2.2failed
Indexing Test0.44failed2.0failed1.2failed
Multithreading Test2.1failed0.98failed1.5failed
All Tests4.4failed1.4failed2.9failed

OpenJPA with PostgreSQL server has failed in 10 tests (see exceptions).

Speed comparison of JPA database update operations (normalized score, higher is better)

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Basic Person Test0.734.91.63.91.24.4
Element Collection Test0.390.0331.24.60.782.3
Inheritance Test0.614.82.14.91.44.9
Indexing Test0.815.12.66.01.75.6
Graph (Binary Tree) Test0.690.570.400.310.540.44
Multithreading Test0.6322.23.07.41.814.8
All Tests0.646.31.84.51.25.4

The results above show that in general OpenJPA with PostgreSQL server is much more efficient than Hibernate with MySQL server in updating JPA entity objects in the database. Comparing the normalized speed of Hibernate with MySQL database server (1.2) to the normalized speed of OpenJPA with PostgreSQL database server (5.4) reveals that in these tests, OpenJPA with PostgreSQL server is 4.5 times faster than Hibernate with MySQL server.

A huge performance gap has been detected when using multithreading with small transaction size. Comparing the normalized speed of Hibernate with MySQL database server (0.63) to the normalized speed of OpenJPA with PostgreSQL database server (22.2) reveals that in that case, OpenJPA with PostgreSQL server is 35.2 times faster than Hibernate with MySQL server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.033) to the normalized speed of Hibernate with MySQL database server (0.39) reveals that in that case, OpenJPA with PostgreSQL server is 11.8 times slower than Hibernate with MySQL server.

Speed comparison of JPA database removal operations (normalized score, higher is better)

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Basic Person Test1.14.61.75.31.45.0
Element Collection Test0.210.0320.532.80.371.4
Inheritance Test0.654.31.84.61.24.4
Indexing Test0.818.02.07.11.47.5
Graph (Binary Tree) Test0.550.530.620.550.580.54
Multithreading Test0.3517.44.19.12.213.3
All Tests0.615.81.84.91.25.4

The results above show that in general OpenJPA with PostgreSQL server is much more efficient than Hibernate with MySQL server in deleting JPA entity objects from the database. Comparing the normalized speed of Hibernate with MySQL database server (1.2) to the normalized speed of OpenJPA with PostgreSQL database server (5.4) reveals that in these tests, OpenJPA with PostgreSQL server is 4.5 times faster than Hibernate with MySQL server.

A huge performance gap has been detected when using multithreading with small transaction size. Comparing the normalized speed of Hibernate with MySQL database server (0.35) to the normalized speed of OpenJPA with PostgreSQL database server (17.4) reveals that in that case, OpenJPA with PostgreSQL server is 49.7 times faster than Hibernate with MySQL server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.032) to the normalized speed of Hibernate with MySQL database server (0.21) reveals that in that case, OpenJPA with PostgreSQL server is 6.6 times slower than Hibernate with MySQL server.

Comparison of JPA/Database speed - the averages (normalized score, higher is better)

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Basic Person Test3.75.13.67.53.66.3
Element Collection Test1.80.720.844.61.32.6
Inheritance Test1.84.74.37.63.16.2
Indexing Test2.06.34.49.73.28.0
Graph (Binary Tree) Test0.830.590.730.500.780.55
Multithreading Test2.118.75.012.23.615.5
All Tests2.16.03.27.02.76.5

The results above show that in general OpenJPA with PostgreSQL server is more efficient than Hibernate with MySQL server in performing JPA database operations. Comparing the normalized speed of Hibernate with MySQL database server (2.7) to the normalized speed of OpenJPA with PostgreSQL database server (6.5) reveals that in these tests, OpenJPA with PostgreSQL server is 2.4 times faster than Hibernate with MySQL server.

A large performance gap has been detected when using multithreading with small transaction/retrieval size. Comparing the normalized speed of Hibernate with MySQL database server (2.1) to the normalized speed of OpenJPA with PostgreSQL database server (18.7) reveals that in that case, OpenJPA with PostgreSQL server is 8.9 times faster than Hibernate with MySQL server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small transaction/retrieval size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.72) to the normalized speed of Hibernate with MySQL database server (1.8) reveals that in that case, OpenJPA with PostgreSQL server is 2.5 times slower than Hibernate with MySQL server.

Other Head to Head DBMS/JPA Comparisons