=?iso-8859-1?Q?Tim_Terleg=E5rd?= <tim@se.linux.org> writes:
> There seems to be only one issue left, batch inserts in postgresql seem
> significant slower than in oracle. I have about 200 batch jobs, each
> consisting of about 14 000 inserts.
> conn.setAutoCommit(false);
> pst = conn.prepareStatement("INSERT INTO tmp (...) VALUES (?,?)");
> for (int i = 0; i < len; i++) {
> pst.setInt(0, 2);
> pst.setString(1, "xxx");
> pst.addBatch();
> }
> pst.executeBatch();
> conn.commit();
Hmm. It's good that you are wrapping this in a transaction, but I
wonder about doing it as a single "batch". I have no idea what the
internal implementation of batches in JDBC is like, but it seems
possible that it would have some performance issues with 14000
statements in a batch.
Have you checked whether the bulk of the runtime is being consumed
on the server or client side?
Also, make sure that the JDBC driver is using "real" prepared statements
--- until pretty recently, it faked them. I think build 311 is new
enough, but it would be good to check in the docs or by asking on pgsql-jdbc.
regards, tom lane