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: Avoid closing frequently executed PreparedStatement
PostPosted: Thu Aug 11, 2005 7:21 pm 
Newbie

Joined: Fri Apr 08, 2005 6:28 pm
Posts: 17
Location: US
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0.5
Database version: Oracle 9.2i
The generated SQL (show_sql=true):
select MoOid.nextval from dual
select MoOid.nextval from dual
select MoOid.nextval from dual
select MoOid.nextval from dual
select MoOid.nextval from dual
select MoOid.nextval from dual

Debug level Hibernate log excerpt:

1845503 2005-08-11 19:06:13,386: [pool-1-thread-4] DEBUG org.hibernate.SQL:324 - select MoOid.nextval from dual
1845503 2005-08-11 19:06:13,386: [pool-1-thread-4] DEBUG org.hibernate.jdbc.AbstractBatcher:378 - preparing statement
1845503 2005-08-11 19:06:13,386: [pool-1-thread-4] DEBUG org.hibernate.jdbc.AbstractBatcher:298 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
1845503 2005-08-11 19:06:13,386: [pool-1-thread-4] DEBUG org.hibernate.jdbc.AbstractBatcher:416 - closing statement
1845519 2005-08-11 19:06:13,402: [pool-1-thread-4] DEBUG org.hibernate.jdbc.AbstractBatcher:290 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
1845519 2005-08-11 19:06:13,402: [pool-1-thread-4] DEBUG org.hibernate.SQL:324 - select MoOid.nextval from dual
1845519 2005-08-11 19:06:13,402: [pool-1-thread-4] DEBUG org.hibernate.jdbc.AbstractBatcher:378 - preparing statement
1845519 2005-08-11 19:06:13,402: [pool-1-thread-4] DEBUG org.hibernate.jdbc.AbstractBatcher:298 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
1845535 2005-08-11 19:06:13,418: [pool-1-thread-4] DEBUG org.hibernate.jdbc.AbstractBatcher:416 - closing statement
etc... (repeated 10,000 times)


Hello!

I am trying to speed up an application inserting several millions of records. Is there a way to prevent Hibernate from closing PreparedStatement for getting the next value of sequence? This statement is executed in the loop, and it would be really nice if Hibernate can chache it...

Thank you,
Dmitri


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 2:47 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
prepared statement caching is the role of your driver or you database.

Do you know if your driver allows prepared statement cachin. Alternatively you may find a pool that do prepared statement caching, see if c3p0 does that (I guess dbcp do it but it is not a recommended option)

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 9:28 am 
Newbie

Joined: Fri Apr 08, 2005 6:28 pm
Posts: 17
Location: US
scesbron wrote:
prepared statement caching is the role of your driver or you database.

Do you know if your driver allows prepared statement cachin. Alternatively you may find a pool that do prepared statement caching, see if c3p0 does that (I guess dbcp do it but it is not a recommended option)


Seb, thank you. Yes, it does. I'm using OracleCachingDataSource, and enable implicit connection statement caching (up to 400) . I was looking for a way to save 10-15 msec. AbstractBatcher needs to go over prepare-close steps.

Thanks,
Dmitri.


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.