PostgreSQL 18 · Performance and maintenance
Cancel a running query
Ask a backend to stop its current query, using a pid from pg_stat_activity.
SELECT pg_cancel_backend(12345);
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
- See running queries
All performance and maintenance commands · PostgreSQL 18 cheatsheet