Compare with

Comparison of OpenJPA with H2 embedded vs OpenJPA with PostgreSQL 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
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test17.15.25.84.811.55.0
Element Collection Test10.92.84.92.27.92.5
Inheritance Test14.34.65.93.210.13.9
Indexing Test24.47.413.76.919.17.1
Graph (Binary Tree) Test6.80.986.70.816.70.89
Multithreading Test34.223.410.29.122.216.2
All Tests17.97.47.94.512.95.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
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test14.65.827.216.120.910.9
Element Collection Test0.00460.0134.38.72.14.4
Inheritance Test0.0115.27.417.63.711.4
Indexing Test17.04.835.018.726.011.8
Graph (Binary Tree) Test1.00.271.40.351.20.31
Multithreading Test18.711.927.623.323.117.6
All Tests8.64.717.114.112.89.4

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
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test5.0failed1.1failed3.1failed
Element Collection Test1.7failed1.3failed1.5failed
Inheritance Test2.2failed1.2failed1.7failed
Indexing Test13.8failed23.2failed18.5failed
Multithreading Test1.4failed0.60failed0.99failed
All Tests4.8failed5.5failed5.1failed

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
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test10.04.96.03.98.04.4
Element Collection Test0.0110.0333.84.61.92.3
Inheritance Test0.0464.85.04.92.54.9
Indexing Test8.95.17.06.08.05.6
Graph (Binary Tree) Test2.40.571.30.311.90.44
Multithreading Test16.622.24.37.410.414.8
All Tests6.36.34.64.55.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
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test18.34.611.15.314.75.0
Element Collection Test0.0120.0322.92.81.41.4
Inheritance Test0.0304.36.64.63.34.4
Indexing Test23.28.09.77.116.47.5
Graph (Binary Tree) Test1.80.532.40.552.10.54
Multithreading Test31.217.417.39.124.213.3
All Tests12.45.88.34.910.45.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
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
OpenJPA
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test13.05.110.27.511.66.3
Element Collection Test2.50.723.44.63.02.6
Inheritance Test3.34.75.27.64.36.2
Indexing Test17.56.317.79.717.68.0
Graph (Binary Tree) Test3.00.593.00.503.00.55
Multithreading Test20.418.712.012.216.215.5
All Tests10.26.08.87.09.56.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