Re: PATCH: Batch/pipelining support for libpq

Craig Ringer <craig@2ndquadrant.com>

From: Craig Ringer <craig@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: "Iwata, Aya" <iwata.aya@jp.fujitsu.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, David Steele <david@pgmasters.net>, Daniel Verite <daniel@manitou-mail.org>, "Prabakaran, Vaishnavi" <VaishnaviP@fast.au.fujitsu.com>, "fujita.etsuro@lab.ntt.co.jp" <fujita.etsuro@lab.ntt.co.jp>, Haribabu Kommi <kommi.haribabu@gmail.com>, Dmitry Igrishin <dmitigr@gmail.com>, Manuel Kniep <m.kniep@web.de>, Michael Paquier <michael.paquier@gmail.com>, "Tsunakawa, Takayuki" <tsunakawa.takay@jp.fujitsu.com>, Vaishnavi Prabakaran <vaishnaviprabakaran@gmail.com>
Date: 2017-06-21T23:44:03Z
Lists: pgsql-hackers
On 22 Jun. 2017 07:40, "Andres Freund" <andres@anarazel.de> wrote:

On 2017-06-20 17:51:23 +0200, Daniel Verite wrote:
>       Andres Freund wrote:
>
> > FWIW, I still think this needs a pgbench or similar example integration,
> > so we can actually properly measure the benefits.
>
> Here's an updated version of the patch I made during review,
> adding \beginbatch and \endbatch to pgbench.
> The performance improvement appears clearly
> with a custom script of this kind:
>   \beginbatch
>      UPDATE pgbench_branches SET bbalance = bbalance + 1 WHERE bid = 0;
>      ..above repeated 1000 times...
>   \endbatch
>
> versus the same with a BEGIN; END; pair instead of \beginbatch \endbatch
>
> On localhost on my desktop I tend to see a 30% difference in favor
> of the batch mode with that kind of test.
> On slower networks there are much bigger differences.

This is seriously impressive.  Just using the normal pgbench mixed
workload, wrapping a whole transaction into a batch *doubles* the
throughput.  And that's locally over a unix socket - the gain over
actual network will be larger.


In my original tests I got over a 300x improvement on WAN :) . I should
check if the same applies with pgbench.

Commits

  1. Add libpq pipeline mode support to pgbench

  2. Implement pipeline mode in libpq