SF
demo/postgresql-performance-first-aid
/
Sign in
© 2026 SetForkExploreAboutSource codeContactTermsPrivacy

PostgreSQL performance first aid

First things to check when Postgres feels slow.

demo/postgresql-performance-first-aid · v1

0 0 v1
demodemov1created via API4 hours ago 1
1
Find the slowest queries

Requires the pg_stat_statements extension.

$SELECT query, calls, mean_exec_time FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 10;
2
Look for sequential scans on big tables
$SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables ORDER BY seq_scan DESC LIMIT 10;
3
EXPLAIN ANALYZE the worst offender
$EXPLAIN (ANALYZE, BUFFERS) <your query>;
4
Add the missing index

Index the columns used in WHERE/JOIN/ORDER BY.

$CREATE INDEX CONCURRENTLY ON orders (customer_id, created_at);
5
Check for table bloat / autovacuum lag
$SELECT relname, n_dead_tup, last_autovacuum FROM pg_stat_user_tables ORDER BY n_dead_tup DESC LIMIT 10;
6
Verify connection pool size vs max_connections
About

First things to check when Postgres feels slow.

postgresperformancedatabase
0 stars 0 forks Releases: v1Latestmaintained by Demo User
Contributors 1
demo
demo

postgresql-performance-first-aid

v1 Public
Star 0
Suggest edit
List Issues Suggestions Versions