Compare with

Comparison of OpenJPA with PostgreSQL server vs Hibernate with MySQL 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
 OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
Basic Person Test5.23.64.81.65.02.6
Element Collection Test2.81.62.20.722.51.1
Inheritance Test4.63.73.21.63.92.7
Indexing Test7.45.46.92.67.14.0
Graph (Binary Tree) Test0.981.50.811.20.891.4
Multithreading Test23.47.49.12.916.25.2
All Tests7.43.94.51.85.92.8

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
 OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
Basic Person Test5.83.016.111.010.97.0
Element Collection Test0.0130.348.71.24.40.79
Inheritance Test5.21.317.614.511.47.9
Indexing Test4.82.518.712.811.87.6
Graph (Binary Tree) Test0.270.550.350.710.310.63
Multithreading Test11.90.2323.313.817.67.0
All Tests4.71.314.19.09.45.2

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
 OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
Basic Person Testfailed10.0failed2.0failed6.0
Element Collection Testfailed6.7failed0.53failed3.6
Inheritance Testfailed2.8failed1.6failed2.2
Indexing Testfailed0.44failed2.0failed1.2
Multithreading Testfailed2.1failed0.98failed1.5
All Testsfailed4.4failed1.4failed2.9

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
 OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
Basic Person Test4.90.733.91.64.41.2
Element Collection Test0.0330.394.61.22.30.78
Inheritance Test4.80.614.92.14.91.4
Indexing Test5.10.816.02.65.61.7
Graph (Binary Tree) Test0.570.690.310.400.440.54
Multithreading Test22.20.637.43.014.81.8
All Tests6.30.644.51.85.41.2

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
 OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
Basic Person Test4.61.15.31.75.01.4
Element Collection Test0.0320.212.80.531.40.37
Inheritance Test4.30.654.61.84.41.2
Indexing Test8.00.817.12.07.51.4
Graph (Binary Tree) Test0.530.550.550.620.540.58
Multithreading Test17.40.359.14.113.32.2
All Tests5.80.614.91.85.41.2

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
 OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
OpenJPA
PostgreSQL server
Hibernate
MySQL server
Basic Person Test5.13.77.53.66.33.6
Element Collection Test0.721.84.60.842.61.3
Inheritance Test4.71.87.64.36.23.1
Indexing Test6.32.09.74.48.03.2
Graph (Binary Tree) Test0.590.830.500.730.550.78
Multithreading Test18.72.112.25.015.53.6
All Tests6.02.17.03.26.52.7

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