cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henning von Bargen <H.vonBar...@Triestram-Partner.de>
Subject AW: Executing Prepared Statement
Date Thu, 25 May 2000 13:03:33 GMT


> -----Urspr√ľngliche Nachricht-----
> Von:	Donald Ball [SMTP:balld@webslingerZ.com]
> Gesendet am:	Donnerstag, 25. Mai 2000 03:06
> An:	cocoon-users@xml.apache.org
> Betreff:	Re: Executing Prepared Statement
> 
> On Wed, 24 May 2000, sudhi wrote:
> 
> > > 
> > > try running it as you would from the sql command line - generally
> > > something like this:
> > > 
> > > call next-article()
> > > 
> > > if you can suggest an appropriate syntax, i'll be happy to add
specific
> > > support for prepared statements in the sql taglib.
> > > 
> > Is it possible to implement it it in the same as java and JDBC ?
> > Like create a statement, and set the fields one by one.
> > (some thing like this)
> >         String sqlstmt = "insert into files (filename,title)
> > values(?,?)"
> >         PreparedStatement stmt = conn.prepareStatement(sqlstmt);
> >         stmt.setString(1,filename);
> >         stmt.setString(2,title);
> 
> what does that get you that generating the query in the XSP page does not?
> 
> - donald

Much better performance (at least with Oracle).
If a statement has _exactly_ the same sql text as a cached previously
executed statement,
then there's no need for Oracle to reparse it and determine how to execute
it internally.
If one uses
"select ENAME from EMP where EMPNO = 10"
and then
"select ENAME from EMP where EMPNO = 20"
these are two different statements, the second one has to go all the way
through parsing,
and determine how to physically fetch the record.
But if one uses
"select ENAME from EMP where EMPNO = ?"
two times with different values for the parameter ?,
then the second statement can be executed much faster, since the "howto
access information"
is still in the cache from the first statement.
This is true for Oracle and I suppose for many other RDBMs as well.
Henning

> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

Mime
View raw message