Top
Enterprise Postgres 17 Operation Guide

17.4.2 Using the ps Command

Follow the procedure below to close a connection using a standard Unix tool (ps command).

  1. Execute the ps command.
    Note that "<x>" indicates the product version.

    > ps axwfo user,pid,ppid,tty,command | grep postgres
    fsepuser 19174 18027 pts/1                 \_ grep postgres
    fsepuser 20517     1 ?      /opt/fsepv<x>server64/bin/postgres -D /disk01/data  
    fsepuser 20518 20517 ?       \_ postgres: logger
    fsepuser 20520 20517 ?       \_ postgres: checkpointer
    fsepuser 20521 20517 ?       \_ postgres: background writer
    fsepuser 20522 20517 ?       \_ postgres: walwriter
    fsepuser 20523 20517 ?       \_ postgres: autovacuum launcher
    fsepuser 20524 20517 ?       \_ postgres: archiver
    fsepuser 20525 20517 ?       \_ postgres: logical replication launcher
    fsepuser 18673 20517 ?       \_ postgres: fsepuser postgres 192.168.100.1(49448) idle
    fsepuser 16643 20517 ?       \_ postgres: fsepuser db01 192.168.100.11(49449) UPDATE waiting
    fsepuser 16644 20517 ?         \_ postgres: fsepuser 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).

  2. 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.

    The example below disconnects the process with ID 16643.

    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.