Compare with

Comparison of OpenJPA with MySQL server vs OpenJPA with H2 embedded

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
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Test0.150.0132.11.31.10.68
Element Collection Testfailed0.0171.31.41.30.73
Inheritance Test0.150.0162.21.41.20.73
Indexing Test0.230.0243.01.31.60.68
Graph (Binary Tree) Testfailed0.0010failedstoppedfailed0.0010
Multithreading Testfailedfailed5.3failed5.3failed
All Tests0.180.0142.81.41.80.63

OpenJPA with MySQL server has failed in 4 tests (see exceptions). OpenJPA with H2 embedded has failed in 2 tests (see exceptions).

The results above show that in general OpenJPA with MySQL server is more efficient than OpenJPA with H2 embedded in persisting JPA entity objects to the database. Comparing the normalized speed of OpenJPA with H2 embedded database (0.63) to the normalized speed of OpenJPA with MySQL database server (1.8) reveals that in these tests, OpenJPA with MySQL server is 2.9 times faster than OpenJPA with H2 embedded.

A huge performance gap has been detected when using simple basic entities with small transaction size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.013) to the normalized speed of OpenJPA with MySQL database server (0.15) reveals that in that case, OpenJPA with MySQL server is 11.5 times faster than OpenJPA with H2 embedded.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Testfailed0.007219.64.019.62.0
Element Collection Testfailed0.00211.21.51.20.73
Inheritance Testfailed0.004617.12.117.11.1
Indexing Testfailed0.007419.23.719.21.9
Graph (Binary Tree) Testfailedstoppedfailedstoppedfailedstopped
Multithreading Testfailedfailed32.4failed32.4failed
All Testsfailed0.005317.92.817.91.4

OpenJPA with MySQL server has failed in 7 tests (see exceptions). OpenJPA with H2 embedded has failed in 2 tests (see exceptions).

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Testfailed1.42.70.542.70.96
Element Collection Testfailed0.921.30.421.30.67
Inheritance Testfailed1.21.20.541.20.85
Indexing Testfailed0.00395.61.55.60.74
Multithreading Testfailedfailedfailedfailedfailedfailed
All Testsfailed0.872.70.742.70.81

OpenJPA with MySQL server has failed in 6 tests (see exceptions). OpenJPA with H2 embedded has failed in 2 tests (see exceptions).

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Teststopped0.0113.43.23.41.6
Element Collection Testfailed0.00591.62.21.61.1
Inheritance Testfailed0.00261.41.11.40.54
Indexing Testfailed0.0113.81.53.80.78
Graph (Binary Tree) Testfailedstoppedfailedstoppedfailedstopped
Multithreading Testfailedfailed8.9failed8.9failed
All Tests0.00000.00773.82.03.81.0

OpenJPA with MySQL server has failed in 6 tests (see exceptions). OpenJPA with H2 embedded has failed in 2 tests (see exceptions).

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Teststopped0.00721.91.61.90.83
Element Collection Testfailed0.00340.610.950.610.47
Inheritance Testfailed0.00572.01.82.00.90
Indexing Testfailed0.00952.61.12.60.56
Graph (Binary Tree) Testfailedstoppedfailedstoppedfailedstopped
Multithreading Testfailedfailed7.1failed7.1failed
All Tests0.00000.00642.81.42.80.69

OpenJPA with MySQL server has failed in 6 tests (see exceptions). OpenJPA with H2 embedded has failed in 2 tests (see exceptions).

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Test0.150.286.02.25.01.2
Element Collection Testfailed0.191.21.31.20.75
Inheritance Test0.150.244.81.44.00.82
Indexing Test0.230.0116.81.85.70.93
Graph (Binary Tree) Testfailed0.0010failedstoppedfailed0.0010
Multithreading Testfailedfailed13.4failed13.4failed
All Tests0.180.176.11.75.50.90

The results above show that in general OpenJPA with MySQL server is much more efficient than OpenJPA with H2 embedded in performing JPA database operations. Comparing the normalized speed of OpenJPA with H2 embedded database (0.90) to the normalized speed of OpenJPA with MySQL database server (5.5) reveals that in these tests, OpenJPA with MySQL server is 6.1 times faster than OpenJPA with H2 embedded.

A huge performance gap has been detected when using database indexes with small transaction/retrieval size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.011) to the normalized speed of OpenJPA with MySQL database server (0.23) reveals that in that case, OpenJPA with MySQL server is 20.9 times faster than OpenJPA with H2 embedded.

Other Head to Head DBMS/JPA Comparisons