-->
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: insert performance
PostPosted: Wed Sep 17, 2003 8:23 am 
hi!

i'm using hibernate (JDK 1.4.2) with sapdb (7.4 the latest stable)

when i want to use hibernate for an import program then hand coded sql seems to be more than twice(!) faster than hibernate.

each object to insert is just a plain object with three attributes:
long (as id)
String
Timestamp

here the code sniplet for the insert:

for (each object to insert) {
Session sess = sessions.openSession();
Transaction tx = sess.beginTransaction();
sess.save(bosEx);
tx.commit();
sess.flush();
sess.close();
}

"bulk" inserts are not acceptable because i shouldn't :-) loose data!

any hints or tips?
many thanx, blip


Top
  
 
 Post subject:
PostPosted: Wed Sep 17, 2003 9:04 am 
Regular
Regular

Joined: Tue Aug 26, 2003 3:09 pm
Posts: 58
First of all, I would move the session open/close and the transaction outside the loop. These tend to be the most expensive operations - you don't want to repeat them for every single insert.

Also, if it needs to work with very large amounts of data, you may want to use jdbc directly.

Joe


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2003 9:14 am 
using the same session results in an OutOfMemoryError .....
i need to know if exactly one entity was correctly inserted.


Top
  
 
 Post subject:
PostPosted: Wed Sep 17, 2003 10:23 am 
SORRY - my mistake!

i didn't activate the PreparedStatement Pooling *uups*
now i'm "just a little bit (20%) faster with handcoded sql (a commit for every object)

BUT with a "bulk" insert (commit after every 1000 objects) HIBERNATE is 8% faster ......


Top
  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 5:30 pm 
Newbie

Joined: Tue Aug 16, 2005 2:18 pm
Posts: 5
blip wrote:
SORRY - my mistake!

i didn't activate the PreparedStatement Pooling *uups*
now i'm "just a little bit (20%) faster with handcoded sql (a commit for every object)

BUT with a "bulk" insert (commit after every 1000 objects) HIBERNATE is 8% faster ......


how to enable PreparedStatement Pooling?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 5:51 pm 
Newbie

Joined: Tue Jul 05, 2005 11:47 pm
Posts: 15
Location: Argentina
blip wrote:
using the same session results in an OutOfMemoryError .....
i need to know if exactly one entity was correctly inserted.


try using session.clear() after the flush.


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.