Benchmark with pgbench postgres
Run 60s load test with 32 clients across 8 threads, progress every 5s
pgbench -c 32 -j 8 -T 60 -P 5 -d <name>; -- init once: pgbench -i -s 100 <name>
more postgres
all 29 commands →
Connect to database
psql -h localhost -U myuser -d mydb
List databases
psql -U postgres -c '\l+'
List tables in schema
psql -U myuser -d mydb -c '\dt public.*'
EXPLAIN ANALYZE a query
psql -U myuser -d mydb -c 'EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) SELECT * FROM orders WHERE status = $1;'
Show slow queries (pg_stat_statements)
psql -U postgres -d mydb -c "SELECT round(total_exec_time::numeric,2) ms, calls, round((total_exec_time/calls)::numeric,2) avg_ms, query FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;"