Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Performace optimisation

 
M Mehta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a java developer has been given a task of improving the performance of a search query. I have seen that the query is bein dynamically generated using the Hibernate criteria API.

I am not sure how should I proceed to improve the performance. Are there any specific rules/tips to be followed in hibernate to improve the perfromance of a query. Some of the things I checked are:
1. The EhCacheProvider is bein used in the application.
2. There are indexes created in the database for each column being used in the where clause of the query.
3. I ran the explain plan on the query being generated by hibernate. But not all the indexes are being listed in the plan. Only the PK indexes are shown.

Can you please provide some tips I can use and proceed on the given task.

Thanks,
Me
 
M Mehta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone help me on this please?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step 1: work out what is causing the performance issue. Don't change a single line of code or reconfigure anything till you've done that.

You can use a bunch of tools to do this. I'd look at timings for the response of the database query first. Explain plans are a good place to start.


2. There are indexes created in the database for each column being used in the where clause of the query.

This is often a mistake. Indices are only hit if values in them are distinct enough. e.g. if an enumeration used only has three possible values on a table with 1000s of values an index can only slow down the database (on inset, update and delete) because it is unlikely to be hit in a query.


3. I ran the explain plan on the query being generated by hibernate. But not all the indexes are being listed in the plan. Only the PK indexes are shown.

This is presumably for the reasons above. If the database is deciding this is the best route to take its difficult to argue.

If you've ruled out the query itself, have a look at the network and the applicaiton performance. What do you do with the results after you've got them? Try profiling the application - are there any hotspots? Is the memory usage high? If you are using a second level cache there's every possibility you are not hitting the database at all (assuming you are also using the query cache). Hibernate will record a bunch of session factory activety - check the docs to see how to get at this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic