Re: How to list what queries are running in postgres? - Mailing list pgsql-admin

From Bruce Momjian
Subject Re: How to list what queries are running in postgres?
Date
Msg-id 200407060227.i662REq15694@candle.pha.pa.us
Whole thread Raw
In response to Re: How to list what queries are running in postgres?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-admin
Tom Lane wrote:
> Gaetano Mendola <mendola@bigfoot.com> writes:
> > P.A.M. van Dam wrote:
> >> I'm looking for a command or method to find out what queries are
> >> currently being serviced by the database.
>
> > select * from pg_stat_activity;
>
> ... having first remembered to turn on stats_command_string; and
> thou shalt also be superuser.

And 7.5 will print out a more helpful message if you forget to set
these:

 test=> select * from pg_stat_activity;
  datid | datname | procpid | usesysid | usename  |        current_query         | query_start
 -------+---------+---------+----------+----------+------------------------------+-------------
  17227 | test    |   15527 |      100 | guest    | <command string not enabled> |
  17227 | test    |   15574 |        1 | postgres | <insufficient privilege>     |
 (2 rows)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: Losing my database connection
Next
From: Bruno Wolff III
Date:
Subject: Re: standard IDENTITY support (Was: Re: SERIAL type not autoincremented)