Re: see all queries incoming

Lists: pgsql-novice
From: Flávio Brito <flavio(at)gral(dot)org(dot)br>
To: pgsql-novice(at)postgresql(dot)org
Subject: see all queries incoming
Date: 2005-08-28 11:47:11
Message-ID: 1125229631.10816.6.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

How can I see, such as MSSQL screen, all queries that are processing in
real time?

I want to monitor all the queries that are being processed by a user in
real time.

Thanks

Flavio


From: Kretschmer Andreas <andreas_kretschmer(at)despammed(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: see all queries incoming
Date: 2005-08-28 12:37:00
Message-ID: 20050828123700.GA1709@kaufbach.delug.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Flávio Brito <flavio(at)gral(dot)org(dot)br> schrieb:

> How can I see, such as MSSQL screen, all queries that are processing in real
> time?
>
> I want to monitor all the queries that are being processed by a user in real
> time.

watch "echo \"SELECT * FROM pg_stat_activity;\" | psql -U <user> <db>

(and enable stats_command_string)

Regards, Andreas
--
Diese Message wurde erstellt mit freundlicher Unterstützung eines freilau-
fenden Pinguins aus artgerechter Freilandhaltung. Er ist garantiert frei
von Micro$oft'schen Viren. (#97922 http://counter.li.org) GPG 7F4584DA
Was, Sie wissen nicht, wo Kaufbach ist? Hier: N 51.05082°, E 13.56889° ;-)


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Kretschmer Andreas <andreas_kretschmer(at)despammed(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: see all queries incoming
Date: 2005-08-28 13:19:23
Message-ID: 20050828131923.GA8100@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Sun, Aug 28, 2005 at 02:37:00PM +0200, Kretschmer Andreas wrote:
> Flávio Brito <flavio(at)gral(dot)org(dot)br> schrieb:
> > How can I see, such as MSSQL screen, all queries that are processing in real
> > time?
> >
> > I want to monitor all the queries that are being processed by a user in real
> > time.
>
> watch "echo \"SELECT * FROM pg_stat_activity;\" | psql -U <user> <db>

Does that actually work on your system? On the system I tested it
sends screen control garbage to the pipe. Aside from that, "watch"
isn't a standard command -- on one of my systems (FreeBSD) I get this:

watch: fatal: cannot open snoop device

On another (Solaris) I get this:

watch: Command not found.

Additionally, periodically doing "SELECT * FROM pg_stat_activity"
isn't a reliable way to see *all* queries, as you'll miss queries
that happened between your SELECTs. It's also wasteful of resources,
especially if you start a new session for each query.

--
Michael Fuhr


From: Kretschmer Andreas <andreas_kretschmer(at)despammed(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: see all queries incoming
Date: 2005-08-28 13:35:31
Message-ID: 20050828133531.GB1709@kaufbach.delug.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Michael Fuhr <mike(at)fuhr(dot)org> schrieb:

> On Sun, Aug 28, 2005 at 02:37:00PM +0200, Kretschmer Andreas wrote:
> > Flávio Brito <flavio(at)gral(dot)org(dot)br> schrieb:
> > > How can I see, such as MSSQL screen, all queries that are processing in real
> > > time?
> > >
> > > I want to monitor all the queries that are being processed by a user in real
> > > time.
> >
> > watch "echo \"SELECT * FROM pg_stat_activity;\" | psql -U <user> <db>
>
> Does that actually work on your system? On the system I tested it

Yes, Debian/Stable with 8.0.3

> Additionally, periodically doing "SELECT * FROM pg_stat_activity"
> isn't a reliable way to see *all* queries, as you'll miss queries

Yupp, correct. PG ist very fast ;-)

Regards, Andreas
--
Diese Message wurde erstellt mit freundlicher Unterstützung eines freilau-
fenden Pinguins aus artgerechter Freilandhaltung. Er ist garantiert frei
von Micro$oft'schen Viren. (#97922 http://counter.li.org) GPG 7F4584DA
Was, Sie wissen nicht, wo Kaufbach ist? Hier: N 51.05082°, E 13.56889° ;-)


From: Flávio Brito <flavio(at)gral(dot)org(dot)br>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: see all queries incoming
Date: 2005-08-28 13:45:48
Message-ID: 1125236748.18742.3.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Em Dom, 2005-08-28 às 14:37 +0200, Kretschmer Andreas escreveu:

> watch "echo \"SELECT * FROM pg_stat_activity;\" | psql -U <user> <db>

After I did it I receive a prompt like this

[flavio(at)localhost flavio]$ watch "echo \"SELECT * FROM pg_stat_activity;
\" | psql -U postgres template1
>
>

Can you help me more? Exist another way to run this query inside of psql
without using "watch"?

Thanks


From: Kretschmer Andreas <andreas_kretschmer(at)despammed(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: see all queries incoming
Date: 2005-08-28 14:26:17
Message-ID: 20050828142617.GC1709@kaufbach.delug.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Flávio Brito <flavio(at)gral(dot)org(dot)br> schrieb:

> Em Dom, 2005-08-28 às 14:37 +0200, Kretschmer Andreas escreveu:
>
> watch "echo \"SELECT * FROM pg_stat_activity;\" | psql -U <user> <db>
>
>
> After I did it I receive a prompt like this

Mmh.

> Can you help me more? Exist another way to run this query inside of psql
> without using "watch"?

Yes, of course, 'SELECT * FROM pg_stat_activity;'.
This is a snapshot for this moment.

Regards, Andreas
--
Diese Message wurde erstellt mit freundlicher Unterstützung eines freilau-
fenden Pinguins aus artgerechter Freilandhaltung. Er ist garantiert frei
von Micro$oft'schen Viren. (#97922 http://counter.li.org) GPG 7F4584DA
Was, Sie wissen nicht, wo Kaufbach ist? Hier: N 51.05082°, E 13.56889° ;-)