Discussion:
How to list what queries are running in postgres?
(too old to reply)
Gaetano Mendola
2004-06-29 21:19:09 UTC
Permalink
Hi!
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;


Regards
Gaetano Mendola
Tom Lane
2004-06-30 03:37:22 UTC
Permalink
Post by Gaetano Mendola
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.

[ anybody else remember Monty Python's scriptures concerning the
Holy Hand Grenade? ]

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ***@postgresql.org so that your
message can get through to the mailing list cleanly
Gaetano Mendola
2004-06-30 08:43:51 UTC
Permalink
Post by Tom Lane
Post by Gaetano Mendola
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.
[ anybody else remember Monty Python's scriptures concerning the
Holy Hand Grenade? ]
Do you mean this ?

Then did he raise on high the Holy Hand Grenade of Antioch, saying,
"Bless this, O Lord, that with it thou mayst blow thine enemies to
tiny bits, in thy mercy." And the people did rejoice and did feast
upon the lambs and toads and tree-sloths and fruit-bats and orangutans
and breakfast cereals ... Now did the Lord say, "First thou pullest
the Holy Pin. Then thou must count to three. Three shall be the number
of the counting and the number of the counting shall be three. Four
shalt thou not count, neither shalt thou count two, excepting that
thou then proceedeth to three. Five is right out. Once the number
three, being the number of the counting, be reached, then lobbest
thou the Holy Hand Grenade in the direction of thine foe, who, being
naughty in my sight, shall snuff it."


:-)


Regards
Gaetano Mendola
Bruce Momjian
2004-07-06 02:27:13 UTC
Permalink
Post by Tom Lane
Post by Gaetano Mendola
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
***@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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
Loading...