Follow the procedure below to close a connection using a standard Unix tool (ps command).
Execute the ps command.
> 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
Process ID 16643 may be a connection that was established a considerable time ago by the UPDATE statement, or a connection that has occupied resources (waiting).
Close connections from clients that have been in the waiting state for an extended period.
Use pg_terminate_backend() to close the connection with the process ID identified in step 1 above.
However, when considering continued compatibility of applications, do not reference or use system catalogs and functions directly in SQL statements.
postgres=# SELECT pg_terminate_backend (16643); pg_terminate_backend ------------------- t (1 row)
See
Refer to "System Administration Functions" under "The SQL Language" in the PostgreSQL Documentation for information on pg_terminate_backend.
Refer to "Notes on Application Compatibility" in the Application Development Guide for information on how to maintain application compatibility.