Re: How to determine number of established connections

From: "Andrus" <eetasoft(at)online(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to determine number of established connections
Date: 2006-02-20 19:33:57
Message-ID: dtd5ma$1obb$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Doug Hall 2006-02-20 19:44:28 Bus error on make check
Previous Message A. Kretschmer 2006-02-20 18:24:12 Re: How to determine number of established connections