Топ-100
 

PostgreSQL: sessions in a database

Session manager in the cluster.

The data is updated manually.  

postgresql session list - query
postgresql session list - query plan
 
Controls

Drop-down list " Query type " - type of SQL query used to retrieve data

  • PostgreSQL version >= 10

  • PostgreSQL version<10

Version >= 10  - for bases version 10 and older

SELECT  datname,
       pid,
       usename,
       application_name,
       cast(client_addr as text),
       to_char(backend_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS backend_start,
       to_char(query_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS query_start,
       state,
       wait_event_type || ': ' || wait_event AS wait_event,
       cast(pg_blocking_pids(pid) as text) AS blocking_pids,
       query,
       backend_type
   FROM pg_stat_activity
ORDER BY pid       

Version < 10  - version bases less than 10

SELECT  datname,
       pid,
       usename,
       application_name,
       cast(client_addr as text),
       to_char(backend_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS backend_start, 
       to_char(query_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS query_start,
       state,
       '' wait_event,
       '---' blocking_pids,
       query,
       '9.0' backend_type
  FROM pg_stat_activity
ORDER BY pid

Control buttons

postgresql session list - controll button
Refresh session list
End current request in session (select pg_cancel_backend($$PID))
Terminate session (select pg_terminate_backend($$PID))
Save session information to a file
Adjust column size

When a session is selected in the "Session list" list, the current SQL query in the session is displayed in the "SQL Text" field.

When switching to the "Query plan" tab, the query execution plan is displayed