Java Persistence/Performance

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.

n queries to retrieve related objects

 * 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

 * SPECjEnterprise2010 - Standard Performance Evaluation Corporation, JEE benchmark that uses JPA extensively.
 * Blog:Java Persistence Performance
 * EclipseLink Performance (Eclipse Wiki)