I've tested this design with a PreparedStatement and a SingleStatment. With
the design used in James adding a user to a MySQL-DB in
AbstractJdbcUsersRepository takes about 450 ms on my machine comparing 10 ms
with a SingleStatement.
Each time lets say AbstractJdbcUsersRepository.doAddUser(User user) is
invoked the PreparedStatement is (seems to be) recompiled which consumes
much more time than a SingleStatement. In the method the Statement is
executed only one time which is the worst case of using a PreparedStatement
(as my sources told me).

Here the general approaches Ive tested:

First the scenario that should gain performance over a SingleStatement:

create PreparedStatement ps;
while(many times) {
    setValues of ps;
    execute ps;
}

Second the standard implementation of james:

method {
    create PreparedStatement ps;
    setValues of ps;
    execute ps;
    ...
}

As you can see the first way creates a PreparedStatement only once and
executes it many times with different Statements.
The second way creates a PreparedStatement each time the method is invoked
and executes the Statement only once.

A strange behavior i encountered was that neigther the
"org.gjt.mm.mysql.Driver"-Driver nor the "com.mysql.jdbc.Driver"-Driver
improved performance compared to a SingleStatement.


----- Original Message -----
From: "Serge Knystautas" <[EMAIL PROTECTED]>
To: "James Developers List" <[EMAIL PROTECTED]>
Sent: Thursday, May 29, 2003 3:20 PM
Subject: Re: PreparedStatement and performance


> typedef_lex wrote:
> > Why did Serge use PreparedStatements in eg
> > JDBCMailRepository.store(MailImpl mc)?
>
> Because you have to store binary data.  Besides, prepared statements
> should be much faster assuming your driver does prepared statement
pooling.
>
> --
> Serge Knystautas
> President
> Lokitech >> software . strategy . design >> http://www.lokitech.com
> p. 301.656.5501
> e. [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to