How to get running queries in PostgreSQL

In this article, we can get the list of users running on PostgreSQL and their queries. Also, we can see particular user running queries and idle users in PostgreSQL.

To get list of users current running.

select usename from pg_stat_activity; To get list of users current running. But, not idle sessions.

SELECT datname,usename,query FROM pg_stat_activity WHERE query != '';

If we have not get the information, then configure the track_activities option in postgresql.conf file or by running following SQL query.

SET track_activities = on

Related Posts

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools
%d bloggers like this: