–tuto tuning psql
–Spot a missing PostgreSQL index
–returns the tables which have been hit by sequential scans the most and tells us how many rows a sequential scan has hit on average.
SELECT schemaname,
relname,
seq_scan,
seq_tup_read,
idx_scan,
seq_tup_read / seq_scan AS avg
FROM pg_stat_user_tables
WHERE seq_scan > 0
ORDER BY seq_tup_read DESC;
–Finding slow queries to be executed on pgadmin
SELECT query,
total_exec_time,
calls,
mean_exec_time
FROM pg_stat_statements
ORDER BY total_exec_time DESC;
Laisser un commentaire