pg_stat_statements
The PostgreSQL extension that answers the question "what is actually taking time in this database". The first thing to enable in production, and almost always the only thing you need.
The extension normalizes each SQL statement by replacing constants with placeholders, so a thousand calls with different IDs count as a single entry. For each entry it collects call count, total and mean execution time, standard deviation, row count, and reads and writes against buffers and disk. Sorting by total time rather than mean is what finds the real culprit — a two-millisecond query run a million times costs more than the report that takes a minute once a night. It requires the library to be loaded in shared_preload_libraries, and therefore a restart.