Thread:

From
"Sherrylyn\(Work\)"
Date:
Hi ,
    Does any one know how I would get a list of users currently connected to a
postgres database? In Oracle, I could select from the vg$sessions table. Is
there a corollary table in Postgres?


Re:

From
Farhan Mughal
Date:
>>Does any one know how I would get a list of users currently connected to a
>>postgres database?


You can view all the database activity by:

select * from pg_stat_activity;

I am not sure about users, but i guess this should serve the purpose:

select COUNT(DISTINCT(client_addr)) from pg_stat_activity;

--Farhan


----- Original Message ----
From: Sherrylyn(Work) <shines@datasof.com>
To: pgsql-admin@postgresql.org
Sent: Thursday, 18 October, 2007 10:42:06 PM
Subject: [ADMIN]

Hi ,
    Does any one know how I would get a list of users currently connected to a
postgres database? In Oracle, I could select from the vg$sessions table. Is
there a corollary table in Postgres?


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@postgresql.org so that your
      message can get through to the mailing list cleanly



For ideas on reducing your carbon footprint visit Yahoo! For Good this month.

Re:

From
Alex Kloss
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sherrylyn(Work) wrote:
> Hi ,
>     Does any one know how I would get a list of users currently
connected to a
> postgres database? In Oracle, I could select from the vg$sessions table. Is
> there a corollary table in Postgres?
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that your
>        message can get through to the mailing list cleanly
>
SELECT usename FROM pg_stat_activity WHERE datname='databasename'

There's many other connection statistics in pg_stat_activity as well,
such as IP address, current query...

Alex Rowe


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHF9y3LGN3BhEHOicRAmOpAJ9ia+gYRRRJORBCXEvnwur3tIScEgCdHugX
E4fzATbhmA0SxYtIQ986xyQ=
=deCX
-----END PGP SIGNATURE-----