-->
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.  [ 7 posts ] 
Author Message
 Post subject: session.find what happens?
PostPosted: Thu Apr 15, 2004 8:06 am 
Newbie

Joined: Fri Mar 12, 2004 10:02 am
Posts: 16
I want to find the optimal tradeoff between network roundtrips and response time. I want to find out how many data should be send to the client at once. Retunning an array of data transfer objects should reduce network roundtrips.

I assume that fetching objects from the cache should be as fast as the database access. The C++ client I made needs about 200ms to display the complete list of 3000 lines.

My first try was shocking slow (5 seconds/3000 lines) and I started analysing the problem. One thing I found was that the hibernate logging is a real performance hit, after switching it off I was at about 1 second/3000 lines. But this is still factor 5 slower than the database query with C++ and measured without the time needed to transfer the data. I found the session.find method as the main consumer. Has anybody an idea what takes so long to fetch the objects from the cache?

Regards
Haug


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 15, 2004 10:01 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
session.find fisrt call a query to retrieve ID and then retrieve instances of associated objects and collections from the cache.
If you know that most of the objects you want to retrieve can be found in the cache, then use query.iterate(), with this, objects and associated objects and collectionsl be retrieved from the cache.

You can also look a the first generated sql, copy paste it into a db client and see if if it is optimized.
It's not because HQL is parsed that you d'ont have to optimize the HQL query.

Anthony


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2004 10:22 am 
Newbie

Joined: Fri Mar 12, 2004 10:02 am
Posts: 16
It seems not to make a difference if you use the find method or the Query object. What I found is an issue with the Oracle JDBC thin driver. It loads the result in about 50ms if and only if you enlarge the statements fetchsize to about 500 or more. If you use the default fetchsize of 10 it needs about 500ms to load the data.
I patched Hibernate to use a fetchsize of 500 and got a 400ms improvement as expected. It seems like a good idea to make it configurable or as parameter for the Query.
My analysis showed that the creation of the data transfer object takes about 100ms. It is an array of 4000 instances with 5 short Strings each. The transfer to the client takes additional 200-300ms on our local 100MBit network.
With the FS500 patch I got an over all runtime for 4000 elements of about 700ms. I can explain 150ms, 50ms for the query and 100ms for object creation. There are 550ms open which I can't explain. What is so expensive that it takes more than half a second?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2004 10:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I am +1 on adding Query.setFetchSize() immediately. Please add a feature request to JIRA.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2004 11:07 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
done: HB-893
http://opensource.atlassian.com/project ... wse/HB-893

haug,
i've just copy/paste your post respecting your signature


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 9:20 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
delpouve wrote:
session.find fisrt call a query to retrieve ID and then retrieve instances of associated objects and collections from the cache.

You mean session.iterate or query.iterate, not session.find

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 10:54 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
yes, excuse for the error


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.