Compare with

Comparison of OpenJPA with MySQL server vs OpenJPA with H2 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
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
Basic Person Test3.93.71.62.22.72.9
Element Collection Test1.62.60.681.51.12.1
Inheritance Test3.64.51.42.02.53.2
Indexing Test5.67.32.43.64.05.4
Graph (Binary Tree) Test0.681.10.570.840.630.97
Multithreading Test7.27.72.74.24.95.9
All Tests3.74.51.52.42.63.4

The results above show that in general OpenJPA with H2 server is more efficient than OpenJPA with MySQL server in persisting JPA entity objects to the database.

A large performance gap has been detected when using JPA element collections with large transaction size. Comparing the normalized speed of OpenJPA with MySQL database server (0.68) to the normalized speed of OpenJPA with H2 database server (1.5) reveals that in that case, OpenJPA with H2 server is 2.2 times faster than OpenJPA with MySQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
Basic Person Test3.22.922.77.612.95.2
Element Collection Test0.00380.00222.91.91.40.93
Inheritance Test0.0170.0136.94.03.42.0
Indexing Test2.44.123.48.812.96.5
Graph (Binary Tree) Test0.270.380.350.490.310.44
Multithreading Test0.145.918.114.09.110.0
All Tests1.02.212.46.16.74.2

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

A large performance gap has been detected when using simple basic entities with large retrieval size. Comparing the normalized speed of OpenJPA with H2 database server (7.6) to the normalized speed of OpenJPA with MySQL database server (22.7) reveals that in that case, OpenJPA with MySQL server is 3.0 times faster than OpenJPA with H2 server.

On the other hand, OpenJPA with MySQL server is slower, for instance, when using multithreading with small retrieval size. Comparing the normalized speed of OpenJPA with MySQL database server (0.14) to the normalized speed of OpenJPA with H2 database server (5.9) reveals that in that case, OpenJPA with MySQL server is 42.1 times slower than OpenJPA with H2 server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
Basic Person Test9.33.72.21.05.82.4
Element Collection Test4.82.01.11.22.91.6
Inheritance Test1.52.80.901.11.22.0
Indexing Test0.313.82.17.51.25.7
Multithreading Test1.90.980.991.01.41.0
All Tests3.62.71.52.42.52.5

The results above show that in general OpenJPA with H2 server is equivalent to OpenJPA with MySQL server in executing the tested JPA queries.

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

On the other hand, OpenJPA with H2 server is slower, for instance, when using simple basic entities with small retrieval size. Comparing the normalized speed of OpenJPA with H2 database server (3.7) to the normalized speed of OpenJPA with MySQL database server (9.3) reveals that in that case, OpenJPA with H2 server is 2.5 times slower than OpenJPA with MySQL server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
Basic Person Test0.743.01.62.01.22.5
Element Collection Test0.0140.00781.71.90.870.94
Inheritance Test0.0480.0342.02.81.01.4
Indexing Test0.742.83.03.21.93.0
Graph (Binary Tree) Test0.450.790.250.430.350.61
Multithreading Test0.557.02.92.51.74.8
All Tests0.422.31.92.11.22.2

The results above show that in general OpenJPA with H2 server is more efficient than OpenJPA with MySQL server in updating JPA entity objects in the database.

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
Basic Person Test0.983.21.72.21.42.7
Element Collection Test0.00990.00600.650.880.330.44
Inheritance Test0.0330.0301.53.10.751.6
Indexing Test0.646.52.03.61.35.1
Graph (Binary Tree) Test0.410.730.430.750.420.74
Multithreading Test0.277.62.95.21.66.4
All Tests0.393.01.52.60.962.8

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

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

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
OpenJPA
MySQL server
OpenJPA
H2 server
Basic Person Test3.63.36.03.04.83.1
Element Collection Test1.30.931.41.51.31.2
Inheritance Test1.01.52.52.61.82.0
Indexing Test1.94.96.65.44.35.1
Graph (Binary Tree) Test0.450.750.400.630.430.69
Multithreading Test2.05.95.55.43.85.6
All Tests1.82.93.93.22.83.0

The results above show that in general OpenJPA with H2 server is slightly more efficient than OpenJPA with MySQL server in performing JPA database operations.

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

On the other hand, OpenJPA with H2 server is slower, for instance, when using simple basic entities with large transaction/retrieval size. Comparing the normalized speed of OpenJPA with H2 database server (3.0) to the normalized speed of OpenJPA with MySQL database server (6.0) reveals that in that case, OpenJPA with H2 server is 2.0 times slower than OpenJPA with MySQL server.

Other Head to Head DBMS/JPA Comparisons