Typical Hibernation Performance Break

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 :


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:

  • first activate SQL logging at Hibernate’s level
  • run the critical use cases (the 20% used 80% of the time) or even all of them if you have that luxury
  • identify suspicious queries and optimize the fetch plan, check if indices are used appropriately, etc
  • involve your DBA
Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » Typical Hibernation Performance Break

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录