These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Query performance
PostPosted: Tue Sep 07, 2010 11:39 am 
Newbie

Joined: Tue Sep 07, 2010 11:28 am
Posts: 2
I'm new to hibernate, but trying to get up to speed as quickly as possible.

I'm currently working through how to optimize a search query, I imagine the first implementation can run up to 30 minutes, so clearly not acceptable.


I have a list of people, who have relationships to other people. From my initial query based upon user input, I use that key to go find other people who they are associated with. I'm new relatively new to the company and to hibernate. So from my list of keys, I've plugged into the existing infrastructure services to gather the related people and some information about them.

So my first query returns the list of people. Then each person in that list goes out and finds many different types of related information. I can't write this in one query due to the multiple relationships, so I have to sub-query for up to several thousand people. In the sub-query, I use existing services which were not optimized since they were mainly used to look up relationships for one person at a time, not thosuands.

It's a bit of a mish mash, but currently HibernateTemplate is being used along with fetch eager. Any guidance on somewhere I can read up on my options, or how you approached a similar issue? I really just want to get started down the right path as it's time sensitive. My understanding is that HibernateTemplate is no longer a preferred approach.


Top
 Profile  
 
 Post subject: Re: Query performance
PostPosted: Tue Sep 07, 2010 3:32 pm 
Newbie

Joined: Mon Aug 02, 2010 11:14 pm
Posts: 10
Hey Man,

Sounds like you are in a bind. Umm I will give you a link, it's part of this website, and it's the hibernate documentation. http://www.hibernate.org/docs.html.
Go here and read the hibernate core documentation.

Quote:
...I imagine the first implementation can run up to 30 minutes...

Where did you hear this from? And what do you mean the first implementation? To set up the server or to run a single query for the first time before you get a pooled connection...? Not sure what you mean here.

Second read into lazy fetching, so not everything gets queried at once hence making things a bit faster since everything will be queried on demand, and you'll have a lot of flexibility with filtering and all.

Going to get many people from one person, your onetomany mapping should take care of it, and their info and their info and so on. If you've mapped out all your relationships properly, you should be set. Not sure where you are trying to increase performance.

Also are you using hibernate in conjunction with anything else? Such as struts1, struts2, spring...or just standard servlet/jsp programming without any frameworks...Or a non-web application. Depending on that using the hibernate template or not will come into focus. But mainly work through the documentation and you should get a firm understanding.

And lastly, hibernate should not necessarily be used to increase performance of your queries (you definitely can but you need to figure out if it is something you require), unless you right direct queries in hibernate. If you have modeled your database properly, and you can issue similar queries that hibernate generates for you and get a good run time you should be set. Also in your configuration file set showsql property to true, and see what sort of sql gets generated, and from there you can "optimize" your mappings, should you chose to do that or should it seem necessary.

Any who, good luck. And do provide feedback to help me understand your needs better, so we can work towards a solution together :).

double R


Top
 Profile  
 
 Post subject: Re: Query performance
PostPosted: Tue Sep 07, 2010 4:18 pm 
Newbie

Joined: Tue Sep 07, 2010 11:28 am
Posts: 2
Thanks SB, I'll try to clarify better, haha.

We do use Spring, and everything I need is mapped out in spring-config. I'm accessing existing DAO's to pull the data I need together, but iterating through a couple thousand results is taking 30 minutes.

The existing DAO's use HibernateTemplate.findByCriteria. Unfortunately for what I need, this is taking way too long so if I can't find a way to speed this up, I have to figure something else out.

I'm thinking at this point that I'll need to write custom queries and avoid the existing DAO's.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.