I have a select query running very long. How will I get a status of that query, like how long will it be running? Whether it is accessing a data from the tables or not.
SELECT datname, pid, state, query, age(clock_timestamp(), query_start) AS age
FROM pg_stat_activity
WHERE state <> 'idle'
AND query NOT LIKE '% FROM pg_stat_activity %'
ORDER BY age;