AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PreparedStatement and SYSDATE Performance Tuning

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
johnhurt@gmail.com
Guest





PostPosted: Mon Aug 22, 2005 6:38 pm    Post subject: PreparedStatement and SYSDATE Performance Tuning Reply with quote



Hi,

I have a quick question. Which is faster as a preparedstatement in a
loop (ie, doesn't get reparsed)? Does anyone have a definitive answer
and not a hunch like me?

1) insert into aaa values (?,?,SYSDATE)
2) insert into aaa values (?,?,?) where 3rd ? is a java.util.Date

Regarding re-parsing, would SYSDATE be considered a literal or a
function-return-value and therefore force a similar statement to be
re-parsed?

Lets say that Oracle is very smart, and doesn't reparse if SYSDATE is
the only function or part of a PreparedStatement that changes. In that
case would...

insert into aaa values (?,?,TRUNC(SYSDATE))

be re-parsed or not?

Back to top
Joan
Guest





PostPosted: Mon Aug 22, 2005 8:28 pm    Post subject: Re: PreparedStatement and SYSDATE Performance Tuning Reply with quote




<johnhurt (AT) gmail (DOT) com> wrote

Quote:
Hi,

I have a quick question. Which is faster as a preparedstatement
in a
loop (ie, doesn't get reparsed)? Does anyone have a definitive
answer
and not a hunch like me?

1) insert into aaa values (?,?,SYSDATE)
2) insert into aaa values (?,?,?) where 3rd ? is a
java.util.Date

Regarding re-parsing, would SYSDATE be considered a literal or
a
function-return-value and therefore force a similar statement
to be
re-parsed?

Lets say that Oracle is very smart, and doesn't reparse if
SYSDATE is
the only function or part of a PreparedStatement that changes.
In that
case would...

insert into aaa values (?,?,TRUNC(SYSDATE))

be re-parsed or not?

If you have a computer maybe you can test it. Not that I'm

implying
that you are lazy or anything.


Back to top
Bill Karwin
Guest





PostPosted: Mon Aug 22, 2005 10:50 pm    Post subject: Re: PreparedStatement and SYSDATE Performance Tuning Reply with quote



[email]johnhurt (AT) gmail (DOT) com[/email] wrote:
Quote:
Regarding re-parsing, would SYSDATE be considered a literal or a
function-return-value and therefore force a similar statement to be
re-parsed?

Probably depends on the RDBMS you are using. I have no idea about the
definitive answer with respect to Oracle.

Try writing a program that does this: prepare such a query with SYSDATE,
and execute insert for a few records, with a few moments of delay in
between. See if the SYSDATE value inserted is progressively later, for
each inserted row. If so, then it's being evaluated as a function at
the time you execute the parameterized query. If the value of the date
is the same for each row, it's probably evaluated at the time you
prepared the query and inserted as a constant.

Btw, this may have very negligible impact on the overall performance of
your app. If performance is your goal, you should concentrate on the
areas most likely to result in high cost to performance, instead of
focusing on tiny details which may make very little difference.

Regards
Bill K.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.