Re: get current queries - Mailing list pgsql-admin

From Chris Miles
Subject Re: get current queries
Date
Msg-id 3F434543.4040104@psychofx.com
Whole thread Raw
In response to get current queries  ("Ramil Sagum" <ramil@astra.ph>)
List pgsql-admin
There is a simple way to get this all from psql.

First edit postgresql.conf and make sure:
    stats_command_string = true

(and restart or HUP postmaster if necessary)

Then connect to your database and use my favorite query:

    SELECT datname,procpid,current_query FROM pg_stat_activity ORDER BY procpid;

which will give you database name, pid and current query (or <IDLE>) for
each current connection to the database.

Note that you will see queries for all databases, not just the one you
connected to.

This is what I use for 7.1, I don't know if it differs for newer versions.

Cheers,
CM

--
Chris Miles
http://chrismiles.info/



Ramil Sagum wrote:

>
> is there any way to see what statements/queries are currently being passed
> on to the database?
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings


pgsql-admin by date:

Previous
From: theguardian@vsnl.net
Date:
Subject: Incremental Backup
Next
From: Raigo77@solo.delfi.ee (Raigo)
Date:
Subject: Starting PostgreSQL 7.3.4 with Webmin on Mandrake 9.1