Re: How to determine number of established connections - Mailing list pgsql-general

From Andrus
Subject Re: How to determine number of established connections
Date
Msg-id dtd5ma$1obb$1@news.hub.org
Whole thread Raw
In response to How to determine number of established connections  ("Andrus" <eetasoft@online.ee>)
Responses Re: How to determine number of established connections  (Michael Fuhr <mike@fuhr.org>)
List pgsql-general
> You could query pg_stat_activity or the underlying statistics
> collector functions.
>
> http://www.postgresql.org/docs/8.1/interactive/monitoring-stats.html
>
> Statistics collector reports lag behind actual activity but they
> might suffice for whatever you're doing.  Why does your application
> need to know this?

I want to licence my application per-connection basic.
I can assume that Postgres 8.1 database or even a whole cluster is accessed
only by my application or sometimes by pgAdmin for administration.
pgAdmin creates 3 rows in pg_stat_activity  table. My application uses only
a single connection so it creates single row in pg_stat_activity table.

So I have a parameter stored in a database called "maximum number of
simultaneous connections".
This determines how many users can simultaneously work with my application


Is the query

select count(distinct client_addr)
from pg_stat_activity

best way do obtain this parameter from Postgres 8.1 ?

or should it be better to check only single database:

select count(distinct client_addr)
from pg_stat_activity
where datname='mycurrentdatabase'

Will those queries work with any postgres.conf and other postgres config
settings and with any user access rights ?

Andrus.



pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: How to determine number of established connections
Next
From: Doug Hall
Date:
Subject: Bus error on make check