db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dyre.Tjeldv...@Sun.COM
Subject Re: Large multi-record insert performance
Date Fri, 16 Mar 2007 14:59:39 GMT
"Sedillo, Derek (Mission Systems)" <Derek.Sedillo@ngc.com> writes:

> Hello Daniel,
>
> Thank you for sharing your finding.  It is interesting to see that using
> executeBatch was actually slower than executeUpdate.
>
> Of these three approaches I find it hard to picture multiple inserts in
> a single transaction using executeUpdate.  Would you mind describing how
> to place multiple inserts into one transaction 'without' using batch
> processing?  I am still a bit new to this paradigm after coming from the
> Oracle/C++ world.

I haven't followed this thread closely, but is there a reason why you
cannot do:

PreparedStatement ps = 
conn.prepareStatement("insert into T values (?, ?, ?)");

conn.setAutoCommit(false);
for (int i = 0; i < 1000; ++i) {
    ps.setX(1, <whatever>);
    ps.setX(2, <whatever>); 
    ps.setX(3, <whatever>);
    ps.executeUpdate();
}
conn.commit();

?

-- 
dt

Mime
View raw message