Timescale Logo


Session Monitor

FROM pg_stat_activity

// Monitors Postgres sessions (SQL)

Few important parameters to know

Pid - Backend Process ID

Datname - Database Name

Usename - User running the query

Application_name - Client Application Name

State - State of Session (e.g. Active, Waiting, Idle ..)

Query - Query executed

Cancel Running Query

SELECT pg_cancel_backend(pid);

// To cancel a running query with pid provided. This is useful in case of killing long running queries (SQL)

Biggest Postgres Table/Indexes by their sizes

  nspname || '.' || relname AS "Object Name", relkind As "Object Type",
  pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC

// Top 20 Big tables/Indexes (Excluding catalog tables) (SQL)

Timescale Logo

Subscribe to the Timescale Newsletter

By submitting, you acknowledge Timescale’s Privacy Policy
2023 © Timescale Inc. All rights reserved.