Analyzing the real-time performance of your queries
The pg_stat_statements
 extension adds the capability to track the execution statistics of queries that are run in a database, including the number of calls, total execution time, the total number of returned rows, and internal information on memory and I/O access.
It is evident how this approach opens up new opportunities in PostgreSQL performance analysis by allowing database admins to get insights directly from the database through SQL and in real time.
Getting ready
The pg_stat_statements
 module is available as a contrib module of PostgreSQL. The extension must be installed as a superuser in the desired databases. It also requires administrators to add the library to the postgresql.conf
 file, as follows:
shared_preload_libraries = 'pg_stat_statements'
This change requires restarting the PostgreSQL server.
Finally, to use it, the extension must be installed...