Query to pg_stat_activity

Started by Carmen Gloria Sepulveda Dedesover 22 years ago2 messagesgeneral
Jump to latest
#1Carmen Gloria Sepulveda Dedes
csepulveda@atichile.com

Hello.

I want to query pg_stat_activity to see the current_query field. I do:

mdbs=# select current_user;
current_user
--------------
postgres
(1 row)

mdbs=# select * from pg_stat_activity;
datid | datname | procpid | usesysid | usename | current_query
-------+---------+---------+----------+----------------+---------------
16976 | mdbs | 8537 | 121 | mdbs_app_owner |
16976 | mdbs | 12378 | 121 | mdbs_app_owner |
16976 | mdbs | 14375 | 1 | postgres |
16976 | mdbs | 14337 | 121 | mdbs_app_owner |

but, "current_query" is null. Why?

Thanks.

CG

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Carmen Gloria Sepulveda Dedes (#1)
Re: Query to pg_stat_activity

Carmen Gloria Sepulveda Dedes <csepulveda@atichile.com> writes:

but, "current_query" is null. Why?

Most likely, you haven't enabled gathering of command line statistics.
See postgresql.conf.

regards, tom lane