Java Persistence/Performance

From Wikibooks, open books for an open world
Jump to navigation Jump to search

There are several facets of performance to consider in a JPA application.

There is database performance, in how the database is tuned and how it responses to requests.

There is object model and data model design, and how they are mapped that influence performance.

There is database access performance, in how many queries are used to retrieve a set of objects.

There is query performance, in how a specific query is optimized.

There is concurrency, scalability and throughput performance, in how well the application scales and functions under load.

There is UI performance in how the user interface and client application interacts with JPA.

Common Problems[edit | edit source]

n queries to retrieve related objects[edit | edit source]

One of the most common performance problems in JPA is when a set of objects are queried, and then their related objects are accessed and loaded one by one.
This is commonly called the "n+1 problem", and can be solved through join fetching or batch fetching.
See, Join Fetching

Links[edit | edit source]