Re: performance libpq vs JDBC

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: performance libpq vs JDBC
Дата
Msg-id 4D0A081E.9010103@archonet.com
обсуждение исходный текст
Ответ на Re: performance libpq vs JDBC  (Werner Scholtes <Werner.Scholtes@heuboe.de>)
Список pgsql-performance
On 16/12/10 12:28, Werner Scholtes wrote:
> Thanks a lot for your advice. I found the difference: My Java program
> sends one huge SQL string containing 1000 INSERT statements separated
> by ';' (without using prepared statements at all!), whereas my C++
> program sends one INSERT statement with parameters to be prepared and
> after that 1000 times parameters. Now I refactured my C++ program to
> send also 1000 INSERT statements in one call to PQexec and reached
> the same performance as my Java program.

So - it was the network round-trip overhead. Like Divakar suggested,
COPY or VALUES (),(),() would work too.

You mention multiple updates/deletes too. Perhaps the cleanest and
fastest method would be to build a TEMP table containing IDs/values
required and join against that for your updates/deletes.

> I just wonder why anyone should use prepared statements at all?

Not everything is a simple INSERT. Preparing saves planning-time on
repeated SELECTs. It also provides some SQL injection safety since you
provide parameters rather than building a SQL string.

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Jayadevan M
Дата:
Сообщение: Re: How to get FK to use new index without restarting the database
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: How to get FK to use new index without restarting the database