Re: get current queries

From: Chris Miles <chris(at)psychofx(dot)com>
To: Ramil Sagum <ramil(at)astra(dot)ph>
Cc: pgsql-admin(at)postgresql(dot)org, Chris Miles <chris(at)psychofx(dot)com>
Subject: Re: get current queries
Date: 2003-08-20 09:54:11
Message-ID: 3F434543.4040104@psychofx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Raigo 2003-08-20 10:41:03 Starting PostgreSQL 7.3.4 with Webmin on Mandrake 9.1
Previous Message Nick Fankhauser 2003-08-20 00:37:38 Re: changing field length