Compare with

Comparison of OpenJPA with PostgreSQL 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
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
Basic Person Test5.217.14.85.85.011.5
Element Collection Test2.810.92.24.92.57.9
Inheritance Test4.614.33.25.93.910.1
Indexing Test7.424.46.913.77.119.1
Graph (Binary Tree) Test0.986.80.816.70.896.7
Multithreading Test23.434.29.110.216.222.2
All Tests7.417.94.57.95.912.9

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

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

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
Basic Person Test5.814.616.127.210.920.9
Element Collection Test0.0130.00468.74.34.42.1
Inheritance Test5.20.01117.67.411.43.7
Indexing Test4.817.018.735.011.826.0
Graph (Binary Tree) Test0.271.00.351.40.311.2
Multithreading Test11.918.723.327.617.623.1
All Tests4.78.614.117.19.412.8

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

A large performance gap has been detected when using graphs of objects with large retrieval size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.35) to the normalized speed of OpenJPA with H2 embedded database (1.4) reveals that in that case, OpenJPA with H2 embedded is 4.0 times faster than OpenJPA with PostgreSQL server.

On the other hand, OpenJPA with H2 embedded is slower, for instance, when using class inheritance in the object model with small retrieval size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.011) to the normalized speed of OpenJPA with PostgreSQL database server (5.2) reveals that in that case, OpenJPA with H2 embedded is 473 times slower than OpenJPA with PostgreSQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
Basic Person Testfailed5.0failed1.1failed3.1
Element Collection Testfailed1.7failed1.3failed1.5
Inheritance Testfailed2.2failed1.2failed1.7
Indexing Testfailed13.8failed23.2failed18.5
Multithreading Testfailed1.4failed0.60failed0.99
All Testsfailed4.8failed5.5failed5.1

OpenJPA with PostgreSQL server has failed in 10 tests (see exceptions).

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
Basic Person Test4.910.03.96.04.48.0
Element Collection Test0.0330.0114.63.82.31.9
Inheritance Test4.80.0464.95.04.92.5
Indexing Test5.18.96.07.05.68.0
Graph (Binary Tree) Test0.572.40.311.30.441.9
Multithreading Test22.216.67.44.314.810.4
All Tests6.36.34.54.65.45.4

The results above show that in general OpenJPA with H2 embedded is equivalent to OpenJPA with PostgreSQL server in updating JPA entity objects in the database.

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

On the other hand, OpenJPA with H2 embedded is slower, for instance, when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.046) to the normalized speed of OpenJPA with PostgreSQL database server (4.8) reveals that in that case, OpenJPA with H2 embedded is 104 times slower than OpenJPA with PostgreSQL server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
Basic Person Test4.618.35.311.15.014.7
Element Collection Test0.0320.0122.82.91.41.4
Inheritance Test4.30.0304.66.64.43.3
Indexing Test8.023.27.19.77.516.4
Graph (Binary Tree) Test0.531.80.552.40.542.1
Multithreading Test17.431.29.117.313.324.2
All Tests5.812.44.98.35.410.4

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

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

On the other hand, OpenJPA with H2 embedded is slower, for instance, when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.030) to the normalized speed of OpenJPA with PostgreSQL database server (4.3) reveals that in that case, OpenJPA with H2 embedded is 143 times slower than OpenJPA with PostgreSQL server.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
Basic Person Test5.113.07.510.26.311.6
Element Collection Test0.722.54.63.42.63.0
Inheritance Test4.73.37.65.26.24.3
Indexing Test6.317.59.717.78.017.6
Graph (Binary Tree) Test0.593.00.503.00.553.0
Multithreading Test18.720.412.212.015.516.2
All Tests6.010.27.08.86.59.5

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

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

Other Head to Head DBMS/JPA Comparisons