-->
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.  [ 6 posts ] 
Author Message
 Post subject: JDBC vs Hibernate insert performance
PostPosted: Fri Nov 03, 2006 1:41 pm 
Newbie

Joined: Fri Sep 29, 2006 4:30 pm
Posts: 7
Hello, i already posted this but did not realize i posted it in the Dutch forum. Sorry for the Cross post!!!!

I am in a situation where the most critical part of our app is when a text file is loaded and millions of rows are inserted from the file. concurrency is not so much an issue since only one thread will do the work.

My requirements are to handle several million of transactions, mySql database already held millions of rows before these tests

My setup is basically a page that calls a session bean with the following code:
http://rafb.net/paste/results/M5s1CJ45.html

My object has 50+ fields and all are VARCHAR 255

i dont yet care about RAW performance, i care about understanding RELATIVE performance between hibernate vs jdbc


Also i understand that performance in hibernate is less because of all the wonderful features hibernate has.


My results are these:
http://picasaweb.google.com/fedevela

In raw insert times (without commit) hibernate is outperformed by a factor of 10

in raw commit times, hibernate is outperformed by a factor of 3

Finally we get to my questions:

    What issues may arise if I switch to a JDBC approach in the parts of my application that require it?

    If i switch to JDBC in certain parts of my code ... what impact may that have in hibernate's cache or other objects?

    How hard is it to program a hibernate dialect (or some other artifact) to bypass some of hibernate's functionality in exchange of performance?


Thank you for reading and maybe answering, i hope my data is useful to you.

Any pointers or suggestions greatly appreciated.

Best regards,

Federico Vela


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 2:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
did you read the docs and wiki about batch operations?

and did you apply those advice ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: JDBC alongside Hibernate
PostPosted: Fri Nov 03, 2006 2:06 pm 
Newbie

Joined: Thu Nov 02, 2006 6:59 pm
Posts: 8
Location: London
I have found that you can comfortably use JDBC alongside Hibernate.

Also see the docs on Session's createSQLQuery() method and the Query class. It is probably better to use those than 'raw' JDBC.

Our unit tests have sometimes shown that updates can conflict with items that are already loaded into the session cache. To overcome this you can clear or evict the objects from the session (See the Session docs).


Top
 Profile  
 
 Post subject: Thanks!
PostPosted: Fri Nov 03, 2006 4:54 pm 
Newbie

Joined: Fri Sep 29, 2006 4:30 pm
Posts: 7
Grant, thank you for your reply,

Your words are full of wisdom, thank you for them, I will try this and post the new hibernate results.

Max, thank you, i found the link for the batch docs:
http://www.hibernate.org/hib_docs/v3/re ... batch.html

I actually developed on my own part of this document, starting from the naive part ;-)

sorry for the newbiness but how do i award ratings to a post?

Best regards,
FV


Top
 Profile  
 
 Post subject: Re: JDBC alongside Hibernate
PostPosted: Fri Nov 03, 2006 5:00 pm 
Newbie

Joined: Fri Sep 29, 2006 4:30 pm
Posts: 7
grant.klopper wrote:
Our unit tests have sometimes shown that updates can conflict with items that are already loaded into the session cache.


That makes a lot of sense!

I hope i will only have to come down away from hibernate in those areas where the performance is of utmost importance.

Right now that only involves insert operations.

I also think that to be able to de-synchronize this process could help a lot, say split the text file into a few threads and have each of them insert.

Am i correct if i say that jdbc inserts have no concurrency issues on the db end?

As long as i'm not pulling that specific file's info while inserting i should be safe from "phantom" rows.

Thanks again to all.


Top
 Profile  
 
 Post subject: Chapter 13.3. The StatelessSession interface
PostPosted: Fri Nov 03, 2006 5:06 pm 
Newbie

Joined: Fri Sep 29, 2006 4:30 pm
Posts: 7
Quote:
A stateless session is a lower-level abstraction, much closer to the underlying JDBC.


Sounds like what i'm looking for.

Thanks all.


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