Hi, With this result i would guess that you do something like (Derby is compiling a new statement for each iteration):
Statement s = conn.createStatement();
for (int i=0;i<200;i++) {
s.executeUpdate("insert into data values("+i+",.....)");
}
Try something like
PreparedStatement s = conn.prepareStatement("insert into data values(?,.....)");
for (int i=0;i<200;i++) {
s.setInt(1, i);
s.setxxxx.....
....
s.executeUpdate();
}
and I'll bet you won't see the same differenec between MySQL and
Derby.
Bernt
>>>>>>>>>>>> Quartz wrote (2007-03-07 09:18:26):
> Hi,
>
> I was wondering why derby is ~200 times slower than mysql on a simple INSERT
> statement.
> I'm not expecting a pure java db to be as fast, but not that slower.
>
> I insert 200 'int' fields in a nearly empty table, with only 1 field as
> primary key.
> I insert rows in ascending PK order and set all fields values.
>
> CREATE TABLE data (
> t int NOT NULL default 0,
> field_1 int NOT NULL default 0,
> field_2 int NOT NULL default 0,
> ...
> PRIMARY KEY (t)
> )
>
>
> Profiling the jvm in sampling mode showed that 89% of the CPU in my test goes
> into compiling the
> statement.
>
> There are lots of Class.getDeclaredMethod(...) callse underneath,
> and uses StringBuffer instead of StringBuilder (jdk 1.5 howver).
>
> Hopefully there are a couple 80%-20% hot spots that could be fixed easily.
>
> Hope you can give derby a boost...
>
>
>
>
> ____________________________________________________________________________________
> Expecting? Get great news right away with email Auto-Check.
> Try the Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
--
Bernt Marius Johnsen, Database Technology Group,
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway
signature.asc
Description: Digital signature
