Re: Finding number of current connections

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Tauren Mills <tauren(at)servlets(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Finding number of current connections
Date: 2001-08-01 11:51:30
Message-ID: 200108011151.f71BpUV01592@jupiter.us.greatbridge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tauren Mills wrote:
> I posted this message to the admin list, but just realized maybe it belongs
> in the general list. Sorry for double posting!
>
> I need to find a way to determine how many concurrent connections are being
> made to the database server at any given time. I'm coming from
> administering a MySQL database and am familiar with the following command:
>
> mysqladmin -uroot -p processlist
>
> This lists something like this:
>
> +-----+------+-----------+----+---------+------+------------------+
> | Id | User | Host | db | Command | Time | Info |
> +-----+------+-----------+----+---------+------+------------------+
> | 307 | root | localhost | | Sleep | 0 | |
> | 308 | root | localhost | | Sleep | 0 | |
> | 309 | root | localhost | | Query | 0 | show processlist |
> +-----+------+-----------+----+---------+------+------------------+

Among alot more statistics down to number of rows returned by
scans, this will be added in v7.2:

pgsql=# select * from pg_stat_database;
datid | datname | numbackends | xact_commit | xact_rollback | blks_read | blks_hit
-------+-----------+-------------+-------------+---------------+-----------+----------
1 | template1 | 0 | 0 | 0 | 0 | 0
19030 | template0 | 0 | 0 | 0 | 0 | 0
19070 | pgsql | 3 | 0 | 0 | 0 | 0
19093 | wieck | 0 | 0 | 0 | 0 | 0
(4 rows)

pgsql=# select * from pg_stat_activity;
datid | datname | procpid | usesysid | usename | current_query
-------+---------+---------+----------+---------+---------------
19070 | pgsql | 1576 | 501 | pgsql |
19070 | pgsql | 1578 | 501 | pgsql |
19070 | pgsql | 1580 | 501 | pgsql |
(3 rows)

The numbers are mostly zero because I haven't activated the
collection of statistics in the config file.

Approximately what you're looking for?

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2001-08-01 11:53:10 Re: Finding number of current connections
Previous Message Jan Wieck 2001-08-01 11:46:09 Re: creating postgres tables using existing table defs