select now() - xact_start AS wait_duration_tran, now() - query_start AS wait_duration_query, query_start,query, application_name, md5(query),wait_event_type, * from pg_stat_activity where state in ('idle in transaction','active') order by wait_duration_query desc 

