I can't find the reference, but I believe that with MySQL 4.x and
Connector/J 3.x, there is some level of precompiling of PreparedStatements
so that there would be some performance gains if you could use the same
PreparedStatement several times.
|---------+---------------------------->
| | Jeff Mathis |
| | <jmathis@predict.|
| | com> |
| | Sent by: |
| | jmathis@stripped|
| | om |
| | |
| | |
| | 21/05/2003 23:39 |
| | Please respond to|
| | jmathis |
| | |
|---------+---------------------------->
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
| To: "java@stripped" <java@stripped>
|
| cc:
|
| Subject: Statements vs PreparedStatements
|
>--------------------------------------------------------------------------------------------------------------------------------------------------|
Hi folks,
I'm using the 3.07 release with mysql 4.04. All our tables are InnoDB
tables. The API has a class per table, with several classes sharing
inheritance heirarchies as appropriate. I've got a central DBStore class
that everything goes through for queries. I have my own set of
"Attribute" classes, LongAttr, IntAttr, DateAttr, etc, that everything
coming from the database becomes rather than using java.sql objects or
primitives. These classes take care of formatting themselves for
queries, using or not using quotes when necessary, etc. When loading
from a resultset, I always call the appropriate getXXX method with a
column index.
For everything I do, I create a statement from my connection, issue the
query, look at the result set, then close the statement. Because mysql
does not "compile" sql and cache it, I have been of the opinion that it
is not necessary to create prepared statements. In contrast, with an
Oracle database, use of PreparedStatements is almost required.
The question is, would using PreparedStatements speed things up? I don't
think I'm suffering from any performance hit now. About the only thing
I've noticed is when tables get a lot of columns (~80 or so), setting
all the attributes seems to be slower. But, programmatically, is it
wrong to do things as I've indicated?
always looking for improvements ...
j
--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:
http://lists.mysql.com/java?unsub=1