-->
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.  [ 9 posts ] 
Author Message
 Post subject: Sluggish performance
PostPosted: Wed Oct 18, 2006 9:29 am 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
I made the hibernate-database part of a program. My boss keeps complianing that Hibernate is degrading the performance too much.

A friend here made a non-hibernate implementation of the interfaces that interact with the database, and he's getting a HUGE performance improvement.

An example: Inserting 7900 objects on a certain table:
With hibernate: 344s
Without: 4s

I would expect a maximum impact of a few seconds from hibernate. But I'm having all this difference.

How can I improve the hibernate access?

I've seen somethings, but they focus mostly on queries. Also, all my classes are lazy.

Any tips?

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 12:55 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
It hard to say with limited information.

If the primary purpose of the application is to insert rows into a table (as the statistics imply), Hibernate is going to lose everytime to direct JDBC -- Hibernate is doing alot more. You could try using evict() to remove objects from the session. Or you might look at using a stateless session.

If there is one critical part of the application where large amounts of data are inserted into a table, you could use a direct JDBC call for that (get a connection by calling session.connection()) and use regular Hibernate calls for all the other db access that your friend would need to handle manually in his app.

Curtis ...

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 4:37 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
After a quick look on Hib. in Action I saw that it's sluggish when it comes to inserting tons of things.

My friend claims that the queries are actually as fast as the ones done without hibernate, so... we will have to make a decison on keeping Hibernate or not in the close future.

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 5:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the docs about batchupdating and understand what an ORM to understand what is going on.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 3:04 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
max wrote:
read the docs about batchupdating and understand what an ORM to understand what is going on.


I read the documentation for batches but couldn't figure out where to put this configuration lines:

hibernate.jdbc.batch_size 20

hibernate.cache.use_second_level_cache false

Where do they go? An example would be neat... :D

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 3:28 pm 
Newbie

Joined: Fri Jun 16, 2006 3:41 pm
Posts: 18
Those two lines go into hibernate.cfg.xml file. Personally I found a value of 20 is too high and takes up way too much memory, so I use 5. I'm having the same performance problem as you and as several other people. With the batch updates turned on things get better but it's still pretty bad.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 4:29 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
Hum... it's bad news then. But thanks for the tip.

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 4:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
do read *all* of the docs about what hibernate performance is about.

batch operations can be done in so many ways...including using raw jdbc or even stored procedures.

Learn what the 1st level cache and 2nd level cache is doing and don't overload them if not needed.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 24, 2006 3:27 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
One thing that came to my mind recently. Boss told me we're gonna be making at least 5 insertions per second in the base, so I guess using cache is not a very apropriate thing. At least from what I've read around and what I can think of it working.

On the other hand... boss also said he'd prefer that all transactions (inserts and updates) were to be commited only at the end of the access by the user (actually another program) because all modifications on a single access to our program, should be guarateed to be commited (in other words.. if something fails, in a blackout for example, everything has to be started over).

We're also dealing with multiple threads acessing the base at the same time.

EDIT: Oh... 1 user == 1 thread

_________________
Falci - Heavy Worker!


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