PostgreSQL 18 · Performance and maintenance
See running queries
List sessions and what they are executing.
SELECT pid, state, query FROM pg_stat_activity;
Official PostgreSQL 18 documentation
More performance and maintenance commands
- See how a query runs
- Create an index
- Create an index without blocking writes
- Vacuum and update statistics
- Cancel a running query
All performance and maintenance commands · PostgreSQL 18 cheatsheet