SELECT pid, age(clock_timestamp(), query_start), usename, query, application_name
FROM pg_stat_activity
ORDER BY query_start desc;