Compare with

Comparison of Hibernate with H2 embedded vs Hibernate 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
 Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Basic Person Test18.14.69.03.013.53.8
Element Collection Test13.03.76.81.19.92.4
Inheritance Test21.06.79.43.115.24.9
Indexing Test29.98.218.44.224.16.2
Graph (Binary Tree) Test17.23.420.13.918.73.7
Multithreading Test36.96.811.55.024.25.9
All Tests22.65.612.53.417.64.5

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

A large performance gap has been detected when using JPA element collections with large transaction size. Comparing the normalized speed of Hibernate with H2 database server (1.1) to the normalized speed of Hibernate with H2 embedded database (6.8) reveals that in that case, Hibernate with H2 embedded is 6.2 times faster than Hibernate with H2 server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Basic Person Test16.63.113.36.015.04.6
Element Collection Test4.31.04.01.14.11.0
Inheritance Test10.42.917.57.613.95.2
Indexing Test10.82.615.27.013.04.8
Graph (Binary Tree) Test2.50.424.01.13.30.78
Multithreading Test16.26.515.710.515.98.5
All Tests10.12.811.65.610.94.2

The results above show that in general Hibernate with H2 embedded is more efficient than Hibernate with H2 server in retrieving JPA entity objects from the database. Comparing the normalized speed of Hibernate with H2 database server (4.2) to the normalized speed of Hibernate with H2 embedded database (10.9) reveals that in these tests, Hibernate with H2 embedded is 2.6 times faster than Hibernate with H2 server.

A large performance gap has been detected when using graphs of objects with small retrieval size. Comparing the normalized speed of Hibernate with H2 database server (0.42) to the normalized speed of Hibernate with H2 embedded database (2.5) reveals that in that case, Hibernate with H2 embedded is 6.0 times faster than Hibernate with H2 server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Basic Person Test4.53.71.21.02.82.3
Element Collection Test4.43.71.40.632.92.2
Inheritance Test3.13.21.51.42.32.3
Indexing Test6.61.710.55.88.63.8
Multithreading Test1.21.10.590.880.891.0
All Tests4.02.73.01.93.52.3

The results above show that in general Hibernate with H2 embedded is more efficient than Hibernate with H2 server in executing the tested JPA queries.

A large performance gap has been detected when using database indexes with small retrieval size. Comparing the normalized speed of Hibernate with H2 database server (1.7) to the normalized speed of Hibernate with H2 embedded database (6.6) reveals that in that case, Hibernate with H2 embedded is 3.9 times faster than Hibernate with H2 server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Basic Person Test12.12.96.51.89.32.4
Element Collection Test7.42.65.31.16.31.9
Inheritance Test10.83.28.52.59.62.9
Indexing Test10.02.97.52.78.82.8
Graph (Binary Tree) Test4.41.22.30.433.40.79
Multithreading Test16.25.64.02.410.14.0
All Tests10.13.15.71.87.92.5

The results above show that in general Hibernate with H2 embedded is much more efficient than Hibernate with H2 server in updating JPA entity objects in the database. Comparing the normalized speed of Hibernate with H2 database server (2.5) to the normalized speed of Hibernate with H2 embedded database (7.9) reveals that in these tests, Hibernate with H2 embedded is 3.2 times faster than Hibernate with H2 server.

A large performance gap has been detected when using graphs of objects with large transaction size. Comparing the normalized speed of Hibernate with H2 database server (0.43) to the normalized speed of Hibernate with H2 embedded database (2.3) reveals that in that case, Hibernate with H2 embedded is 5.3 times faster than Hibernate with H2 server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Basic Person Test19.73.811.42.415.53.1
Element Collection Test6.91.94.51.15.71.5
Inheritance Test15.63.712.92.514.23.1
Indexing Test23.27.612.43.117.85.3
Graph (Binary Tree) Test4.00.994.20.914.10.95
Multithreading Test27.46.122.77.325.06.7
All Tests16.14.011.42.913.73.5

The results above show that in general Hibernate with H2 embedded is much more efficient than Hibernate with H2 server in deleting JPA entity objects from the database. Comparing the normalized speed of Hibernate with H2 database server (3.5) to the normalized speed of Hibernate with H2 embedded database (13.7) reveals that in these tests, Hibernate with H2 embedded is 3.9 times faster than Hibernate with H2 server.

A large performance gap has been detected when using simple basic entities with small transaction size. Comparing the normalized speed of Hibernate with H2 database server (3.8) to the normalized speed of Hibernate with H2 embedded database (19.7) reveals that in that case, Hibernate with H2 embedded is 5.2 times faster than Hibernate with H2 server.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Hibernate
H2 embedded
Hibernate
H2 server
Basic Person Test14.23.68.32.811.23.2
Element Collection Test7.22.64.41.05.81.8
Inheritance Test12.24.09.93.411.03.7
Indexing Test16.14.612.84.514.54.6
Graph (Binary Tree) Test7.01.57.71.67.31.6
Multithreading Test19.65.210.95.215.25.2
All Tests12.93.79.03.211.03.4

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

A large performance gap has been detected when using graphs of objects with large transaction/retrieval size. Comparing the normalized speed of Hibernate with H2 database server (1.6) to the normalized speed of Hibernate with H2 embedded database (7.7) reveals that in that case, Hibernate with H2 embedded is 4.8 times faster than Hibernate with H2 server.

Other Head to Head DBMS/JPA Comparisons