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



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to