Thread: View running Processes ?

View running Processes ?

From
Arnaud Lesauvage
Date:
Hi List !

Is there an equivalent of mysql's "SHOW PROCESSLIST" command in
PostgreS ?
Sometimes my server takes a lot of processing power, and I would
like to know what it is doing.

Also, is there no way to kill a running query from *within*
postgres ? With a query, or something similar ?
The only way I found to kill running queries was to "kill <pid>"
from a command prompt, but that is not very clean, I can't run
this from a remote client.

Thanks a lot !

Regards
--
Arnaud



Re: View running Processes ?

From
"A. Kretschmer"
Date:
am  24.02.2006, um 10:32:26 +0100 mailte Arnaud Lesauvage folgendes:
> Hi List !
>
> Is there an equivalent of mysql's "SHOW PROCESSLIST" command in
> PostgreS ?

select * from pg_stat_activity;
You should set
stats_command_string = on

in your postgresql.conf



HTH, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

Re: View running Processes ?

From
Arnaud Lesauvage
Date:
A. Kretschmer a écrit :
> select * from pg_stat_activity;
> You should set
> stats_command_string = on
>
> in your postgresql.conf


Thanks Andreas ! Exactly what I was looking for !

Since you don't mention it, I understand that there is no way to
stop a running query from a postgresql wlient application ?


Regards
--
Arnaud


Re: View running Processes ?

From
"A. Kretschmer"
Date:
am  24.02.2006, um 10:32:26 +0100 mailte Arnaud Lesauvage folgendes:
> Also, is there no way to kill a running query from *within*
> postgres ? With a query, or something similar ?

http://www.postgresql.org/docs/8.1/interactive/functions-admin.html
pg_cancel_backend(pid int)


HTH, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

Re: View running Processes ?

From
Arnaud Lesauvage
Date:
A. Kretschmer a écrit :
> http://www.postgresql.org/docs/8.1/interactive/functions-admin.html
> pg_cancel_backend(pid int)

Oh yes ! So if I understand correctly, I get the pid of the query
with "select * from pg_stat_activity;", then I just kill the query
with "select pg_cancel_backend(<pid>);" ?
Very nice !

PS : Sorry for asking this kind of questions when the answers are
in the doc, but I find it quite difficult to find informations in
the only doc. Maybe it is because I am used to access and mysql,
and the terminology used in postgres is quite different...


Regard
--
Arnaud


Re: View running Processes ?

From
"A. Kretschmer"
Date:
am  24.02.2006, um 11:00:33 +0100 mailte Arnaud Lesauvage folgendes:
> A. Kretschmer a écrit :
> >select * from pg_stat_activity;
> >You should set stats_command_string = on
> >in your postgresql.conf
>
>
> Thanks Andreas ! Exactly what I was looking for !
>
> Since you don't mention it, I understand that there is no way to stop a
> running query from a postgresql wlient application ?

See my other answer, and you can set

statement_timeout = <timeout in ms>

Aborts any statement that takes over the specified number of
milliseconds. A value of zero turns off the timer.


See also:
http://www.powerpostgresql.com/Downloads/annotated_conf_80.html


HTH, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===