A collection of PostgreSQL queries I only use occasionally.
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";CREATE TABLE foo (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4()
);SELECT pg_size_pretty(pg_relation_size('foo'));SELECT table_name,
pg_relation_size(quote_ident(table_name)),
pg_size_pretty(pg_relation_size(quote_ident(table_name)))
FROM information_schema.tables
WHERE table_schema = 'public'
ORDER BY 2 DESC;SELECT * FROM pg_stat_activity WHERE state = 'active' AND pid <> pg_backend_pid();SELECT pg_terminate_backend(pid);