Compare with

Comparison of Hibernate with PostgreSQL server vs DataNucleus 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
 Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Basic Person Test7.119.23.48.05.213.6
Element Collection Test2.96.61.72.82.34.7
Inheritance Test7.015.63.64.45.310.0
Indexing Test9.324.46.111.87.718.1
Graph (Binary Tree) Test3.09.22.96.22.97.7
Multithreading Test31.734.913.97.122.821.0
All Tests10.218.35.36.77.712.5

The results above show that in general DataNucleus with H2 embedded is more efficient than Hibernate with PostgreSQL server in persisting JPA entity objects to the database.

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

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Basic Person Test5.513.211.513.58.513.3
Element Collection Test0.0256.40.0178.90.0217.7
Inheritance Test5.212.214.012.79.612.4
Indexing Test4.68.113.316.58.912.3
Graph (Binary Tree) Test0.6110.60.7820.90.7015.8
Multithreading Test11.313.317.09.914.211.6
All Tests4.510.69.413.77.012.2

The results above show that in general DataNucleus with H2 embedded is more efficient than Hibernate with PostgreSQL server in retrieving JPA entity objects from the database.

A huge performance gap has been detected when using JPA element collections with large retrieval size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.017) to the normalized speed of DataNucleus with H2 embedded database (8.9) reveals that in that case, DataNucleus with H2 embedded is 524 times faster than Hibernate with PostgreSQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Basic Person Test55.54.76.11.430.83.1
Element Collection Test11.05.00.0162.45.53.7
Inheritance Test52.33.88.71.630.52.7
Indexing Test0.0500.00418.81.84.40.91
Multithreading Test55.21.29.20.7932.21.0
All Tests34.83.06.61.620.72.3

The results above show that in general Hibernate with PostgreSQL server is much more efficient than DataNucleus with H2 embedded in executing the tested JPA queries. Comparing the normalized speed of DataNucleus with H2 embedded database (2.3) to the normalized speed of Hibernate with PostgreSQL database server (20.7) reveals that in these tests, Hibernate with PostgreSQL server is 9.0 times faster than DataNucleus with H2 embedded.

A huge performance gap has been detected when using multithreading with small retrieval size. Comparing the normalized speed of DataNucleus with H2 embedded database (1.2) to the normalized speed of Hibernate with PostgreSQL database server (55.2) reveals that in that case, Hibernate with PostgreSQL server is 46.0 times faster than DataNucleus with H2 embedded.

On the other hand, Hibernate with PostgreSQL server is slower, for instance, when using JPA element collections with large retrieval size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.016) to the normalized speed of DataNucleus with H2 embedded database (2.4) reveals that in that case, Hibernate with PostgreSQL server is 150 times slower than DataNucleus with H2 embedded.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Basic Person Test5.310.02.73.94.06.9
Element Collection Test0.0677.60.0263.90.0465.8
Inheritance Test5.49.43.84.44.66.9
Indexing Test5.410.64.35.94.88.2
Graph (Binary Tree) Test1.15.90.583.70.824.8
Multithreading Test29.6failed6.3failed18.0failed
All Tests7.88.72.94.45.46.5

DataNucleus with H2 embedded has failed in 2 tests (see exceptions).

The results above show that in general DataNucleus with H2 embedded is slightly more efficient than Hibernate with PostgreSQL server in updating JPA entity objects in the database.

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Basic Person Test5.34.24.21.34.82.8
Element Collection Test0.0204.9stopped1.60.00983.2
Inheritance Test5.14.04.21.34.62.7
Indexing Test9.57.56.31.97.94.7
Graph (Binary Tree) Test0.0125.60.0124.10.0124.8
Multithreading Test23.3failed21.8failed22.5failed
All Tests7.25.26.12.06.63.6

DataNucleus with H2 embedded has failed in 2 tests (see exceptions).

The results above show that in general Hibernate with PostgreSQL server is more efficient than DataNucleus with H2 embedded in deleting JPA entity objects from the database.

A large performance gap has been detected when using database indexes with large transaction size. Comparing the normalized speed of DataNucleus with H2 embedded database (1.9) to the normalized speed of Hibernate with PostgreSQL database server (6.3) reveals that in that case, Hibernate with PostgreSQL server is 3.3 times faster than DataNucleus with H2 embedded.

On the other hand, Hibernate with PostgreSQL server is slower, for instance, when using graphs of objects with small transaction size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.012) to the normalized speed of DataNucleus with H2 embedded database (5.6) reveals that in that case, Hibernate with PostgreSQL server is 467 times slower than DataNucleus with H2 embedded.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Hibernate
PostgreSQL server
DataNucleus
H2 embedded
Basic Person Test15.710.35.65.610.77.9
Element Collection Test2.86.10.353.91.65.0
Inheritance Test15.09.06.94.910.96.9
Indexing Test5.810.17.87.66.88.9
Graph (Binary Tree) Test1.27.81.18.71.18.3
Multithreading Test30.216.513.65.921.911.2
All Tests12.19.66.06.09.17.8

The results above show that in general Hibernate with PostgreSQL server is slightly more efficient than DataNucleus with H2 embedded in performing JPA database operations.

A large performance gap has been detected when using multithreading with large transaction/retrieval size. Comparing the normalized speed of DataNucleus with H2 embedded database (5.9) to the normalized speed of Hibernate with PostgreSQL database server (13.6) reveals that in that case, Hibernate with PostgreSQL server is 2.3 times faster than DataNucleus with H2 embedded.

On the other hand, Hibernate with PostgreSQL server is slower, for instance, when using JPA element collections with large transaction/retrieval size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.35) to the normalized speed of DataNucleus with H2 embedded database (3.9) reveals that in that case, Hibernate with PostgreSQL server is 11.1 times slower than DataNucleus with H2 embedded.

Other Head to Head DBMS/JPA Comparisons