On 26 June 2018 12:32:44 CEST, Andreas Kretschmer wrote: > > >Am 26.06.2018 um 12:19 schrieb amandeep singh: >> We have been observing our postgres database from past few days,We >> found few queries running three times simultaneously with same >> parameters.I would like to back track how a query is running multiple > >> times. > >they are independend each other. You can run those queries with EXPLAIN > >ANALYSE to see the execution plan. > >Regards, Andreas seems like i misunderstud your query. are you sure, that the parameter $1 is equal across all different connections? Andreas -- 2ndQuadrant - The PostgreSQL Support Company
This query will show you the pid, client_addr and user that submitted the queries, in addition to other useful information.
SELECT backend_start as be_start, datname, pid as pid, client_addr, usename as user, state, query, wait_event_type, query_start, current_timestamp - query_start as duration FROM pg_stat_activity WHERE pg_backend_pid() <> pid ORDER BY 1, datname, query_start;