Re: batch inserts are "slow"

Список
Период
Сортировка
От Tom Lane
Тема Re: batch inserts are "slow"
Дата
Msg-id 18686.1115047799@sss.pgh.pa.us
обсуждение исходный текст
Ответ на batch inserts are "slow"  (Tim Terlegård)
Список pgsql-performance
Дерево обсуждения
batch inserts are "slow"  (Tim Terlegård, )
 Re: batch inserts are "slow"  (Christopher Kings-Lynne, )
 Re: batch inserts are "slow"  (Christopher Petrilli, )
  Re: batch inserts are "slow"  (Tim Terlegård, )
   Re: batch inserts are "slow"  (Steve Wampler, )
   Re: batch inserts are "slow"  (Christopher Petrilli, )
 Re: batch inserts are "slow"  (Tim Terlegård, )
  Re: batch inserts are "slow"  (Christopher Petrilli, )
 Re: batch inserts are "slow"  (Tom Lane, )
 Re: batch inserts are "slow"  ("David Parker", )
  Re: batch inserts are "slow"  (Markus Schaber, )
   Re: batch inserts are "slow"  (Josh Berkus, )
    Re: batch inserts are "slow"  (Kris Jurka, )
     Re: batch inserts are "slow"  (Dave Cramer, )
   Testing list access  (Jona, )
 Re: batch inserts are "slow"  (Chris Browne, )
=?iso-8859-1?Q?Tim_Terleg=E5rd?= <> 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

В списке pgsql-performance по дате отправления:

Предыдущее
От: Chris Browne
Дата:
Сообщение: Re: batch inserts are "slow"
Следующее
От: Markus Schaber
Дата:
Сообщение: Re: [HACKERS] Bad n_distinct estimation; hacks suggested?