-->
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: Caching of Prepared Statements for UPDATES and/or INSERTS
PostPosted: Mon Jul 17, 2006 2:32 pm 
Newbie

Joined: Fri Jun 30, 2006 5:30 pm
Posts: 13
Why does Hibernate only cache MULTIPLE prepared statements for queries, and not for updates/inserts?

I can see this would not work in every situation, but in some it would be most handy. Is this a feature you would like implemented?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 17, 2006 8:58 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
No idea why, but I can suggest why not. Prepared statements are reasonably lightweight and don't take long to construct. Inserts and updates are simple operations, referring to columns in a single table. There isn't much advantage to caching the statements on the java side. And the database caches execution plans on the server side, so you get that performance benefit whether you use an old statement object, or a new one.

Query statements, however, can be very complex, referring to many tables, inclyuding subselects, and thus can involve some overhead at creation time. So hibernate can cache them, to avoid creating them more than once.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 18, 2006 12:45 pm 
Newbie

Joined: Fri Jun 30, 2006 5:30 pm
Posts: 13
OK, that makes sense.

Caching multiple statements for insert/updates would allow you to take advantage of jdbc driver level batching. The way Hibernate deals with the prepared statements now prevents the drivers from doing this.

I'd like to know if it's something the team would actually be interested in adding to the project before I go off and spend the time to implement it.


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.