Обсуждение: Connections to DB

Поиск
Список
Период
Сортировка

Connections to DB

От
"Onyx"
Дата:

How can I view the current, persistent connections to a database?  Is there a way to do this with 'psql' or with some other PostgreSQL bundled tool/utility (~pgsql_directory/bin), instead of resorting to the underlying operating system commands (ie: netstat -a | grep postgres)?

I am interested in finding out the following: 1) How many connections are there to the database? 2) How long have they persisted?  3)  What is the idle time of the connections?

Any help would be appreciated.  Thanks!

- Onyx
---
Onyx Mueller
Software Engineer
i-cubed : information integration & imaging LLC
201 Linden Street : Third Floor
Fort Collins, CO  80524
970-482-4400 voice
970-482-4499 fax
www.i3.com
 

Re: Connections to DB

От
"Jim C. Nasby"
Дата:
SELECT * FROM pg_stat_activity;

Note that if you turn on stats_command_string you'll also be able to see
what each connection is doing if you're connected as a superuser.

On Thu, Oct 27, 2005 at 11:21:26AM -0600, Onyx wrote:
> How can I view the current, persistent connections to a database?  Is there
> a way to do this with 'psql' or with some other PostgreSQL bundled
> tool/utility (~pgsql_directory/bin), instead of resorting to the underlying
> operating system commands (ie: netstat -a | grep postgres)?
>
> I am interested in finding out the following: 1) How many connections are
> there to the database? 2) How long have they persisted?  3)  What is the
> idle time of the connections?
>
> Any help would be appreciated.  Thanks!
>
>
> - Onyx
> ---
> Onyx Mueller
> Software Engineer
> i-cubed : information integration & imaging LLC
> 201 Linden Street : Third Floor
> Fort Collins, CO  80524
> 970-482-4400 voice
> 970-482-4499 fax
> www.i3.com
>
>

--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

Re: Connections to DB

От
Tony Caduto
Дата:
Jim C. Nasby wrote:

>SELECT * FROM pg_stat_activity;
>
>Note that if you turn on stats_command_string you'll also be able to see
>what each connection is doing if you're connected as a superuser.
>
>
>
>
Just as a little FYI, on 8.1  pg_stat_activity  will show the IP address
and port as well, but only on 8.1.

Tony