Hello Moohanad,
Did you check for pg_stat_statements
https://www.postgresql.org/docs/10/static/pgstatstatements.html ?
This is based on postgres hooks and will give you: db,user,query id, query
text
There are many developments trying to add start /end time, planid, plan text
as described in
http://www.postgresql-archive.org/Poc-pg-stat-statements-with-planid-td6014027.html
remark: this extension doen't care about statements finished in error or
timeout
Regards
PAscal
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html