pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: pgbench: Prepare commands in pipelines in advance 3+ messages / 1 participants [nested] [flat]
* pgsql: pgbench: Prepare commands in pipelines in advance @ 2023-02-21 10:15 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 3+ messages in thread From: Alvaro Herrera @ 2023-02-21 10:15 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org pgbench: Prepare commands in pipelines in advance Failing to do so results in an error when a pgbench script tries to start a serializable transaction inside a pipeline, because by the time BEGIN ISOLATION LEVEL SERIALIZABLE is executed, we're already in a transaction that has acquired a snapshot, so the server rightfully complains. We can work around that by preparing all commands in the pipeline before actually starting the pipeline. This changes the existing code in two aspects: first, we now prepare each command individually at the point where that command is about to be executed; previously, we would prepare all commands in a script as soon as the first command of that script would be executed. It's hard to see that this would make much of a difference (particularly since it only affects the first time to execute each script in a client), but I didn't actually try to measure it. Secondly, we no longer use PQsendPrepare() in pipeline mode, but only PQprepare. There's no specific reason for this change other than no longer needing to do differently in pipeline mode. (Previously we had no choice, because in pipeline mode PQprepare could not be used.) Backpatch to 14, where pgbench got support for pipeline mode. Reported-by: Yugo NAGATA <nagata@sraoss.co.jp> Discussion: https://postgr.es/m/20210716153013.fc53b1c780b06fccc07a7f0d@sraoss.co.jp Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/038f586d5f1d90c6ed58544a068696bb81a4e12e Modified Files -------------- src/bin/pgbench/pgbench.c | 158 ++++++++++++++++++--------- src/bin/pgbench/t/001_pgbench_with_server.pl | 20 ++++ 2 files changed, 127 insertions(+), 51 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: pgbench: Prepare commands in pipelines in advance @ 2023-02-21 10:15 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 3+ messages in thread From: Alvaro Herrera @ 2023-02-21 10:15 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org pgbench: Prepare commands in pipelines in advance Failing to do so results in an error when a pgbench script tries to start a serializable transaction inside a pipeline, because by the time BEGIN ISOLATION LEVEL SERIALIZABLE is executed, we're already in a transaction that has acquired a snapshot, so the server rightfully complains. We can work around that by preparing all commands in the pipeline before actually starting the pipeline. This changes the existing code in two aspects: first, we now prepare each command individually at the point where that command is about to be executed; previously, we would prepare all commands in a script as soon as the first command of that script would be executed. It's hard to see that this would make much of a difference (particularly since it only affects the first time to execute each script in a client), but I didn't actually try to measure it. Secondly, we no longer use PQsendPrepare() in pipeline mode, but only PQprepare. There's no specific reason for this change other than no longer needing to do differently in pipeline mode. (Previously we had no choice, because in pipeline mode PQprepare could not be used.) Backpatch to 14, where pgbench got support for pipeline mode. Reported-by: Yugo NAGATA <nagata@sraoss.co.jp> Discussion: https://postgr.es/m/20210716153013.fc53b1c780b06fccc07a7f0d@sraoss.co.jp Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/108a22bd14d4deb98340deec422cfec6d3b37840 Modified Files -------------- src/bin/pgbench/pgbench.c | 159 ++++++++++++++++++--------- src/bin/pgbench/t/001_pgbench_with_server.pl | 20 ++++ 2 files changed, 127 insertions(+), 52 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: pgbench: Prepare commands in pipelines in advance @ 2023-02-21 10:15 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 3+ messages in thread From: Alvaro Herrera @ 2023-02-21 10:15 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org pgbench: Prepare commands in pipelines in advance Failing to do so results in an error when a pgbench script tries to start a serializable transaction inside a pipeline, because by the time BEGIN ISOLATION LEVEL SERIALIZABLE is executed, we're already in a transaction that has acquired a snapshot, so the server rightfully complains. We can work around that by preparing all commands in the pipeline before actually starting the pipeline. This changes the existing code in two aspects: first, we now prepare each command individually at the point where that command is about to be executed; previously, we would prepare all commands in a script as soon as the first command of that script would be executed. It's hard to see that this would make much of a difference (particularly since it only affects the first time to execute each script in a client), but I didn't actually try to measure it. Secondly, we no longer use PQsendPrepare() in pipeline mode, but only PQprepare. There's no specific reason for this change other than no longer needing to do differently in pipeline mode. (Previously we had no choice, because in pipeline mode PQprepare could not be used.) Backpatch to 14, where pgbench got support for pipeline mode. Reported-by: Yugo NAGATA <nagata@sraoss.co.jp> Discussion: https://postgr.es/m/20210716153013.fc53b1c780b06fccc07a7f0d@sraoss.co.jp Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/663e50e8321192f30559a7dd68a912c43a44dcbb Modified Files -------------- src/bin/pgbench/pgbench.c | 162 ++++++++++++++++++--------- src/bin/pgbench/t/001_pgbench_with_server.pl | 20 ++++ 2 files changed, 130 insertions(+), 52 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-02-21 10:15 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-02-21 10:15 pgsql: pgbench: Prepare commands in pipelines in advance Alvaro Herrera <alvherre@alvh.no-ip.org> 2023-02-21 10:15 pgsql: pgbench: Prepare commands in pipelines in advance Alvaro Herrera <alvherre@alvh.no-ip.org> 2023-02-21 10:15 pgsql: pgbench: Prepare commands in pipelines in advance Alvaro Herrera <alvherre@alvh.no-ip.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox