On Tue, 28 Dec 2004, Scott Marlowe wrote:
> Assuming that stats_row_level = true is set in the postgresql.conf file,
> you can find out with:
>
> SELECT * from pg_stat_activity;
>
pg_stat_activity does not require row level stats. To get the command
string in this view you need stats_command_string enabled, but again
that's not necessary to just see open connections.
This method doesn't seem like a real solution to the problem at hand
though. How are you going to determine if you are allowed to make a
connection to the database? By making a connection to the database and
querying this view? Note also that the pg_stat_activity view lags reality
by up to a half a second. Note also that the max_connections setting is
per cluster, not per database, so you cannot know or control what other
clients are going to do with other databases.
I would definitely consider a connection pool as others have
suggested and possibly moving away from frames entirely.
Kris Jurka