How to get a status of a running query in postgresql database

Based on @Anshu answer I am using:

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;

This can't be done yet, but is on the TODO.


we can find the query log with respect to the database in postgres .

select *
from pg_stat_activity
where datname = 'yourdatabasename'

This will give active query log of database .