any way to query for current connections to db?

Started by Coarr, Mattover 18 years ago8 messagesgeneral
Jump to latest
#1Coarr, Matt
mcoarr@mitre.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

#2Jeff Larsen
jlar310@gmail.com
In reply to: Coarr, Matt (#1)
Re: any way to query for current connections to db?

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;

#3Bruce Momjian
bruce@momjian.us
In reply to: Jeff Larsen (#2)
Re: any way to query for current connections to db?

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. +

#4Scott Marlowe
scott.marlowe@gmail.com
In reply to: Coarr, Matt (#1)
Re: any way to query for current connections to db?

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

#5Noname
volunteer@spatiallink.org
In reply to: Scott Marlowe (#4)
Re: any way to query for current connections to db?

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

#6Scott Marlowe
scott.marlowe@gmail.com
In reply to: Bruce Momjian (#3)
Re: any way to query for current connections to db?

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.

#7Jeff Larsen
jlar310@gmail.com
In reply to: Scott Marlowe (#6)
Re: any way to query for current connections to db?

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

#8Bruce Momjian
bruce@momjian.us
In reply to: Scott Marlowe (#6)
Re: any way to query for current connections to db?

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. +