Обсуждение: any way to query for current connections to db?

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

any way to query for current connections to db?

От
"Coarr, Matt"
Дата:
Hi,
 
Is there any way to query the database to identify what the current connections are (connections, sessions, or whatever you want to call them)?
 
This would be something similar to oracle's v$session view.
 
Thanks,
Matt

Re: any way to query for current connections to db?

От
"Jeff Larsen"
Дата:
> Is there any way to query the database to identify what the current
> connections are (connections, sessions, or whatever you want to call them)?

select * from pg_stat_activity;

Re: any way to query for current connections to db?

От
Bruce Momjian
Дата:
Jeff Larsen wrote:
> > Is there any way to query the database to identify what the current
> > connections are (connections, sessions, or whatever you want to call them)?
>
> select * from pg_stat_activity;

Is this an FAQ?

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: any way to query for current connections to db?

От
"Scott Marlowe"
Дата:
On Nov 9, 2007 4:36 PM, Coarr, Matt <mcoarr@mitre.org> wrote:
>
> Is there any way to query the database to identify what the current
> connections are (connections, sessions, or whatever you want to call them)?
>
> This would be something similar to oracle's v$session view.

select * from pg_stat_activity where datname='mydbname'

should get you started.

You can see all the system tables with
\dS
in psql

Re: any way to query for current connections to db?

От
"Scott Marlowe"
Дата:
On Nov 9, 2007 4:57 PM, Bruce Momjian <bruce@momjian.us> wrote:
> Jeff Larsen wrote:
> > > Is there any way to query the database to identify what the current
> > > connections are (connections, sessions, or whatever you want to call them)?
> >
> > select * from pg_stat_activity;
>
> Is this an FAQ?

Yes, it gets asked a lot.

Is it in the FAQ?  Don't know.

Re: any way to query for current connections to db?

От
volunteer@spatiallink.org
Дата:
select
 *
from
 pg_stat_activity
where
 datname = (
 select
  *
 from
  current_database()
 );

-------- Original Message --------
Subject: [GENERAL] any way to query for current connections to db?
From: "Coarr, Matt" <mcoarr@mitre.org>
Date: Fri, November 09, 2007 5:36 pm
To: <pgsql-general@postgresql.org>

Hi,

Is there any way to query the database to identify what the current
connections are (connections, sessions, or whatever you want to call
them)?

This would be something similar to oracle's v$session view.

Thanks,
Matt


Re: any way to query for current connections to db?

От
"Jeff Larsen"
Дата:
> > Is this an FAQ?
>
> Yes, it gets asked a lot.
>
> Is it in the FAQ?  Don't know.

In the FAQ? No
In the Manual? Yes

Re: any way to query for current connections to db?

От
Bruce Momjian
Дата:
Scott Marlowe wrote:
> On Nov 9, 2007 4:57 PM, Bruce Momjian <bruce@momjian.us> wrote:
> > Jeff Larsen wrote:
> > > > Is there any way to query the database to identify what the current
> > > > connections are (connections, sessions, or whatever you want to call them)?
> > >
> > > select * from pg_stat_activity;
> >
> > Is this an FAQ?
>
> Yes, it gets asked a lot.
>
> Is it in the FAQ?  Don't know.

No, it isn't.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +