The view pg_stat_activity shows one row per server process and details about it associated user session and query. The columns that report data on the current query are available unless the parameter stats_command_string has been turned off. Furthermore, these columns are only visible if the user examining the view is a superuser or the same as the user owning the process being reported on.
The maximum length of the query text sting stored in the column current_query can be controlled with the server configuration parameter pgstat_track_activity_query_size.
|procpid||integer||Process ID of the server process|
|current_query||text||Current query that process is running|
|waiting||boolean||True if waiting on a lock, false if not waiting|
|query_start||Time query began execution|
|backend_start||Time backend process was started|
|application_name||text||Client application name|
|xact_start||Transaction start time|
|waiting_reason||text||Reason the server process is waiting. The value