On Sun, Dec 15, 2013 at 8:18 AM, Yuri Levinsky <yuril@xxxxxxxxxxxx> wrote:
pg_stat_activity is the right table, but you have to be the super-user to see queries by others. Here's what I use:
Dear ALL,
I am running PL/pgsql procedure with sql statements that taking a long time. I able to see them in the log just after their completion. How can I see currently running SQL statement? I am able to see in pg_stat_activity only my call to function. Many thanks in advance.
pg_stat_activity is the right table, but you have to be the super-user to see queries by others. Here's what I use:
$ psql -U postgres
postgres=# select procpid, datname, usename, current_query from pg_stat_activity where current_query !~ '<IDLE>';
Craig
Sincerely yours,
Yuri Levinsky, DBA
Celltick Technologies Ltd., 32 Maskit St., Herzliya 46733, Israel
Mobile: +972 54 6107703, Office: +972 9 9710239; Fax: +972 9 9710222