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 Test3.917.11.65.82.711.5
Element Collection Test1.610.90.684.91.17.9
Inheritance Test3.614.31.45.92.510.1
Indexing Test5.624.42.413.74.019.1
Graph (Binary Tree) Test0.686.80.576.70.636.7
Multithreading Test7.234.22.710.24.922.2
All Tests3.717.91.57.92.612.9

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

A huge performance gap has been detected when using graphs of objects with large transaction size. Comparing the normalized speed of OpenJPA with MySQL database server (0.57) to the normalized speed of OpenJPA with H2 embedded database (6.7) reveals that in that case, OpenJPA with H2 embedded is 11.8 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 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Test3.214.622.727.212.920.9
Element Collection Test0.00380.00462.94.31.42.1
Inheritance Test0.0170.0116.97.43.43.7
Indexing Test2.417.023.435.012.926.0
Graph (Binary Tree) Test0.271.00.351.40.311.2
Multithreading Test0.1418.718.127.69.123.1
All Tests1.08.612.417.16.712.8

The results above show that in general OpenJPA with H2 embedded is more efficient than OpenJPA 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 OpenJPA with MySQL database server (0.14) to the normalized speed of OpenJPA with H2 embedded database (18.7) reveals that in that case, OpenJPA with H2 embedded is 134 times faster than OpenJPA with MySQL server.

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 Test9.35.02.21.15.83.1
Element Collection Test4.81.71.11.32.91.5
Inheritance Test1.52.20.901.21.21.7
Indexing Test0.3113.82.123.21.218.5
Multithreading Test1.91.40.990.601.40.99
All Tests3.64.81.55.52.55.1

The results above show that in general OpenJPA with H2 embedded is more efficient than OpenJPA with MySQL server in executing the tested JPA queries. Comparing the normalized speed of OpenJPA with MySQL database server (2.5) to the normalized speed of OpenJPA with H2 embedded database (5.1) reveals that in these tests, OpenJPA with H2 embedded is 2.0 times faster than OpenJPA with MySQL server.

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 embedded database (13.8) reveals that in that case, OpenJPA with H2 embedded is 44.5 times faster than OpenJPA with MySQL server.

On the other hand, OpenJPA with H2 embedded is slower, for instance, when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with H2 embedded database (1.7) to the normalized speed of OpenJPA with MySQL database server (4.8) reveals that in that case, OpenJPA with H2 embedded is 2.8 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 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Test0.7410.01.66.01.28.0
Element Collection Test0.0140.0111.73.80.871.9
Inheritance Test0.0480.0462.05.01.02.5
Indexing Test0.748.93.07.01.98.0
Graph (Binary Tree) Test0.452.40.251.30.351.9
Multithreading Test0.5516.62.94.31.710.4
All Tests0.426.31.94.61.25.4

The results above show that in general OpenJPA with H2 embedded is much more efficient than OpenJPA with MySQL server in updating JPA entity objects in the database. Comparing the normalized speed of OpenJPA with MySQL database server (1.2) to the normalized speed of OpenJPA with H2 embedded database (5.4) reveals that in these tests, OpenJPA with H2 embedded is 4.5 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.55) to the normalized speed of OpenJPA with H2 embedded database (16.6) reveals that in that case, OpenJPA with H2 embedded is 30.2 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 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Test0.9818.31.711.11.414.7
Element Collection Test0.00990.0120.652.90.331.4
Inheritance Test0.0330.0301.56.60.753.3
Indexing Test0.6423.22.09.71.316.4
Graph (Binary Tree) Test0.411.80.432.40.422.1
Multithreading Test0.2731.22.917.31.624.2
All Tests0.3912.41.58.30.9610.4

The results above show that in general OpenJPA with H2 embedded is much 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 embedded database (10.4) reveals that in these tests, OpenJPA with H2 embedded is 10.8 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 embedded database (31.2) reveals that in that case, OpenJPA with H2 embedded is 116 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 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
OpenJPA
MySQL server
OpenJPA
H2 embedded
Basic Person Test3.613.06.010.24.811.6
Element Collection Test1.32.51.43.41.33.0
Inheritance Test1.03.32.55.21.84.3
Indexing Test1.917.56.617.74.317.6
Graph (Binary Tree) Test0.453.00.403.00.433.0
Multithreading Test2.020.45.512.03.816.2
All Tests1.810.23.98.82.89.5

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

A huge 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 embedded database (20.4) reveals that in that case, OpenJPA with H2 embedded is 10.2 times faster than OpenJPA with MySQL server.

Other Head to Head DBMS/JPA Comparisons