aspose file tools*
The moose likes Object Relational Mapping and the fly likes Performace optimisation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Performace optimisation" Watch "Performace optimisation" New topic
Author

Performace optimisation

M Mehta
Ranch Hand

Joined: Aug 03, 2006
Posts: 92
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

Joined: Aug 03, 2006
Posts: 92
Can anyone help me on this please?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Performace optimisation
 
Similar Threads
Query Optimization
iflex interview
Database errors and Hibernate
Which tool to use
Prepared statement, Execution plan and Indexes