Re: How to determine number of established connections

Поиск
Список
Период
Сортировка
От Andrus
Тема Re: How to determine number of established connections
Дата
Msg-id dtd5ma$1obb$1@news.hub.org
обсуждение исходный текст
Ответ на How to determine number of established connections  ("Andrus" <eetasoft@online.ee>)
Ответы Re: How to determine number of established connections  (Michael Fuhr <mike@fuhr.org>)
Список 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 по дате отправления:

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: How to determine number of established connections
Следующее
От: Doug Hall
Дата:
Сообщение: Bus error on make check