pg_stat_statements
is a contributed extension for PostgreSQL that logs all queries and how long they took. If you aggregate on this, you can determine where your PostgreSQL spends the most time and what to optimize.
How it works and how you install it is for another blog post.
Total time
SELECT
(total_time / 1000 / 60) AS total,
(total_time/calls) AS avg, calls,
SUBSTRING(query FROM 0 FOR 250)
FROM pg_stat_statements
WHERE calls > 100
ORDER BY 1 DESC
LIMIT 25;
This one is important because you could have some terribly slow query that uses lots of sequential scans, but perhaps it's only used once a week, so who cares?