Re: batch inserts are "slow"
От
Christopher Kings-Lynne
Тема
Re: batch inserts are "slow"
Дата
Msg-id
427642E9.2080500@familyhealth.com.au
Ответ на
batch inserts are "slow" (Tim Terlegård)
Список
Дерево обсуждения
batch inserts are "slow" Tim Terlegård <tim@se.linux.org>
Re: batch inserts are "slow" Tom Lane <tgl@sss.pgh.pa.us>
Re: batch inserts are "slow" Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Re: batch inserts are "slow" Christopher Petrilli <petrilli@gmail.com>
Re: batch inserts are "slow" Tim Terlegård <tim@se.linux.org>
Re: batch inserts are "slow" Steve Wampler <swampler@noao.edu>
Re: batch inserts are "slow" Christopher Petrilli <petrilli@gmail.com>
> 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();
>
> This snip takes 1.3 secs in postgresql. How can I lower that?
You're batching them as one transaction, and using a prepared query both
of which are good. I guess the next step for a great performance
improvement is to use the COPY command. However, you'd have to find out
how to access that via Java.
I have a nasty suspicion that the release JDBC driver doesn't support it
and you may have to apply a patch.
Ask on pgsql-jdbc@postgresql.org perhaps.
Chris
В списке pgsql-performance по дате отправления