pg_stat_statements is a PostgreSQL extension that accumulates statistics per normalized query: number of calls, total and mean time, rows returned, blocks read. It lets you identify the most expensive or most frequent queries to target optimization. It must be loaded at server startup and then created in the database.
Example
SELECT query, calls, mean_exec_time
FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 5;