Re: High-water Mark for number of sessions/connections reached in Postgres

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: "Tomeh, Husam" <HTomeh(at)corelogic(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: High-water Mark for number of sessions/connections reached in Postgres
Date: 2010-08-09 22:29:58
Message-ID: AANLkTimdgjUwnBo1N1j40oBE6pVgupoG7CGBweX_Nw-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

If you want a date stamp, you can change the ps ax stuff to look like this:

date +"%Y-%m-%d %H:%M:%S"|tr "\n" ":";ps ax|grep postgres:|grep -v grep|wc -l

On Mon, Aug 9, 2010 at 4:21 PM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> wrote:
> On Fri, Aug 6, 2010 at 6:19 PM, Tomeh, Husam <HTomeh(at)corelogic(dot)com> wrote:
>> I was wondering if we can query/obtain the high-water mark of number of sessions or connections reached in a Postgres database. Is there a view or command that can provide this information.  The pg_stat_database shows the current number of connections, but not the high-water mark a database had reached.
>
> It's a pretty easy thing to approximate with a shell script.
>
> while true;do ps ax|grep postgres:|grep -v grep|wc -l ;sleep 10;done >
> connects.log &
>
> then just tail the connects.log file.  It's a dirty hack and it'll be
> a few counts over due to counting the postmaster and a few other
> processes, but it'll give you a good idea of what your system is
> doing.  Add a date in there if you need to know the time it was
> happening.
>

--
To understand recursion, one must first understand recursion.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Alvaro Herrera 2010-08-09 22:39:16 Re: High-water Mark for number of sessions/connections reached in Postgres
Previous Message Scott Marlowe 2010-08-09 22:21:13 Re: High-water Mark for number of sessions/connections reached in Postgres