Check out example codes for "postgres get running query". It will help you in understanding the concepts better.

Code Example 1

--Version > 9.2
SELECT pid, age(clock_timestamp(), query_start), usename, query 
FROM pg_stat_activity 
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' 
ORDER BY query_start desc;

Learn ReactJs, React Native from akashmittal.com