標準的なUnixツール(psコマンド)を使用する場合、以下の手順でコネクションを切断します。
psコマンドを実行します。
> ps axwfo user,pid,ppid,tty,command | grep postgres
symfo 19174 18027 pts/1 \_ grep postgres
symfo 20517 1 ? /opt/symfoserver64/bin/postgres -D /disk01/data
symfo 20518 20517 ? \_ postgres: logger process
symfo 20520 20517 ? \_ postgres: checkpointer process
symfo 20521 20517 ? \_ postgres: writer process
symfo 20522 20517 ? \_ postgres: wal writer process
symfo 20523 20517 ? \_ postgres: autovacuum launcher process
symfo 20524 20517 ? \_ postgres: archiver process
symfo 20525 20517 ? \_ postgres: stats collector process
symfo 18673 20517 ? \_ postgres: symfo postgres 192.168.100.1(49448) idle
symfo 16643 20517 ? \_ postgres: symfo db01 192.168.100.11(49449) UPDATE waiting
symfo 16644 20517 ? \_ postgres: symfo db01 192.168.100.12(49450) idle in transaction
プロセスID(16643)は、UPDATE文で長時間接続したコネクションや、資源を占有したコネクション(waiting)の可能性があります。
長時間、待ち状態のクライアントのコネクションを切断します。
pg_terminate_backend()を利用して、上記1.で特定したプロセスIDのコネクションを切断します。
ただし、アプリケーションの互換性を維持することを考慮し、下記のSQL文中の関数を使用しないようにしてください。
postgres=# SELECT pg_terminate_backend (16643); pg_terminate_backend ------------------- t (1 行)
参照
pg_terminate_backendの詳細は、“PostgreSQL文書”の“SQL言語”の“システム管理関数”を参照してください。
アプリケーションの互換性の維持に関する詳細は、“アプリケーション開発ガイド”の“アプリケーションの互換に関する注意事項”を参照してください。