PgBouncer: add prepared statement statistics - #24607
Open
maufl wants to merge 2 commits into
Open
Conversation
Collect the prepared statement counters PgBouncer 1.24+ exposes in SHOW STATS (client/server parse counts and bind counts) and the prepared_statements column from SHOW CLIENTS and SHOW SERVERS (1.21+), so prepared statement usage through the pooler is observable. Co-Authored-By: Fable 5 (nono) <noreply@anthropic.com>
Co-Authored-By: Fable 5 (nono) <noreply@anthropic.com>
estherk15
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds prepared statement metrics to the PgBouncer check:
SHOW STATS(PgBouncer 1.24+):pgbouncer.stats.{client_parse_count,server_parse_count,bind_count}_per_secondand theiravg_*gauges.SHOW CLIENTS/SHOW SERVERS(PgBouncer 1.21+):pgbouncer.clients.prepared_statementsandpgbouncer.servers.prepared_statements, collected under the existingcollect_per_client_metrics/collect_per_server_metricsoptions.On older PgBouncer versions the columns are absent and the metrics are simply not emitted. Adds a 1.24 entry to the test matrix and version-gated e2e assertions; verified against live PgBouncer 1.24.1 (values populated in transaction pooling mode with
max_prepared_statements > 0) and 1.23.1.Motivation
PgBouncer supports protocol-level named prepared statements since 1.21 and exposes usage counters since 1.24; the integration didn't collect them, leaving prepared statement behavior through the pooler invisible.
Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged