A simple way to identify slow Postgres SQLs
I've just learned probably the simplest way to identify slow Postgres queries in your application.
Postgres has the built-in extension named pg_stat_statements that tracks the executed SQLs, their execution times, and other things.
First of all, you can enable the extension with: CREATE EXTENSION pg_stat_statements;. It's built-in, so no installation is needed.
Now you need to run 2 SQLs to be able to use this extension:
* ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements'; –
Book of Revenue