We have just finish to profile our application. ( she’s begin to be slow ).
the problem seems to be “in hibernate”.
It’s a legacy mapping. Who work’s, and do it’s job. The relational shema behind is ok too.
But some request are slow as hell.
So, we would appreciate any input on common and usual mistake made with hibernate who end up with slow response.
Exemple : Eager in place of Lazy can change dramaticly the response time….
Edit : As usual, read the manual is often a good idea. A whole chapter cover this subject here :
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html
One of the most common pitfalls is the infamous n+1 selects problem. By default, Hibernate doesn’t load data you didn’t ask for. This reduces memory consumptions but exposes you to the n+1 selects problem which can be avoided by switching to the right fetching strategy to retrieve all the data you need to load objects in their appropriately initialized state.
But also don’t fetch too much or you’ll run into the opposite problem, the cartesian product issue: instead of executing to many SQL statements, you may end up creating statements that retrieve too much data.
That’s the whole point of the tuning: finding the middle between not enough and too much data for each use case of your application (or at least, for the one that require to be tuned).
My recommendations: