Search Postgresql Archives

Re: How to determine number of established connections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux