pgsql: Add libpq pipeline mode support to pgbench

Started by Alvaro Herreraover 5 years ago4 messageshackerscomitters
Jump to latest
#1Alvaro Herrera
alvherre@2ndquadrant.com
hackerscomitters

Add libpq pipeline mode support to pgbench

New metacommands \startpipeline and \endpipeline allow the user to run
queries in libpq pipeline mode.

Author: Daniel Vérité <daniel@manitou-mail.org>
Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: /messages/by-id/b4e34135-2bd9-4b8a-94ca-27d760da26d7@manitou-mail.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9aa491abbf07ca8385a429385be8d68517384fdf

Modified Files
--------------
doc/src/sgml/ref/pgbench.sgml | 22 +++++
src/bin/pgbench/pgbench.c | 131 ++++++++++++++++++++++++---
src/bin/pgbench/t/001_pgbench_with_server.pl | 79 +++++++++++++++-
3 files changed, 216 insertions(+), 16 deletions(-)

#2Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Alvaro Herrera (#1)
hackerscomitters
Re: pgsql: Add libpq pipeline mode support to pgbench

Bonjour Daniel, Ola Alvaro,

Add libpq pipeline mode support to pgbench

New metacommands \startpipeline and \endpipeline allow the user to run
queries in libpq pipeline mode.

Author: Daniel Vérité <daniel@manitou-mail.org>
Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: /messages/by-id/b4e34135-2bd9-4b8a-94ca-27d760da26d7@manitou-mail.org

I did not notice that the libpq pipeline mode thread had a pgbench patch
attached, otherwise I would have looked at it.

Some minor post-commit comments:

For consistency with the existing \if … \endif, ISTM that it could have
been named \batch … \endbatch or \pipeline … \endpipeline?

ISTM that the constraint checks (nesting, no \[ag]set) could be added to
CheckConditional that could be renamed to CheckScript. That could allow to
simplify the checks in the command execution as mere Asserts.

--
Fabien.

#3Daniel Verite
daniel@manitou-mail.org
In reply to: Fabien COELHO (#2)
hackerscomitters
Re: pgsql: Add libpq pipeline mode support to pgbench

Fabien COELHO wrote:

For consistency with the existing \if … \endif, ISTM that it could have
been named \batch … \endbatch or \pipeline … \endpipeline?

"start" mirrors "end". To me, the analogy with \if-\endif is not
obvious.
Grammatically \if is meant to introduce the expression after it,
whereas \startpipeline takes no argument.
Functionally \startpipeline can be thought as "open the valve"
and \endpipeline "close the valve". They're "call-to-action" kinds of
commands, and in that sense quite different from the \if-\endif pair.

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: https://www.manitou-mail.org
Twitter: @DanielVerite

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Daniel Verite (#3)
hackerscomitters
Re: pgsql: Add libpq pipeline mode support to pgbench

On 2021-Mar-17, Daniel Verite wrote:

Fabien COELHO wrote:

For consistency with the existing \if … \endif, ISTM that it could have
been named \batch … \endbatch or \pipeline … \endpipeline?

"start" mirrors "end". To me, the analogy with \if-\endif is not
obvious.
Grammatically \if is meant to introduce the expression after it,
whereas \startpipeline takes no argument.
Functionally \startpipeline can be thought as "open the valve"
and \endpipeline "close the valve". They're "call-to-action" kinds of
commands, and in that sense quite different from the \if-\endif pair.

I forgot to reply to this, but I did consider the naming of these
commands before commit, and I tend to side with Daniel here. I think
it's not totally unreasonable to have in the future another command
\syncpipeline which sends does PQpipelineSync(); if the commands are
\pipeline and \endpipeline then a \syncpipeline in the middle makes less
sense than if they are \startpipeline and \endpipeline. I grant this is
quite subjective, though.

--
Álvaro Herrera Valdivia, Chile