DBAtlas · データベース運用アトラス

PgBouncerのプール、統計、接続を表示(SHOW POOLS/STATS/CLIENTS/SERVERS)

PostgreSQLPgBouncer

コマンド

# Connect to the PgBouncer admin console (user must be in admin_users/stats_users):
psql -h 127.0.0.1 -p 6432 -U pgbouncer -d pgbouncer -X
SHOW POOLS;    -- if cl_waiting > 0 and maxwait grows, the pool is saturated
SHOW STATS;    -- per-database total/average query, transaction and wait times
SHOW CLIENTS;  -- client connections (state, source address, linked server connection)
SHOW SERVERS;  -- server connections opened to PostgreSQL
SHOW CONFIG;

概要

各データベース/ユーザーのプールについて、アクティブおよび待機中のクライアント(cl_active、cl_waiting)、アクティブ/アイドルのサーバー接続(sv_active、sv_idle)、最長待機時間(maxwait)、クエリ/トランザクションのカウンタを表示する。

使用する場面

アプリケーションが接続失敗/タイムアウトを報告したとき、プールのサイジング、メンテナンス前のアクティブ接続の確認に。

注意

管理コンソールはSQLを受け付けず、PgBouncerのコマンドのみを実行する。cl_waitingが高いままの場合、まずサーバー側で長時間のトランザクションやロックを確認する。default_pool_sizeを闇雲に引き上げると、PostgreSQLはmax_connectionsの上限とメモリ圧迫に近づく。SHOW STATSの値は累積値で、平均はstats_periodの間隔に基づく。

DBAtlas で開く →

関連項目