pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: pg_stat_activity
Date: Mon, 11 Jun 2018 10:07:49 -0500
Message-ID: <211b19ea-18dc-6897-3c53-8d994550cd15@gmail.com> (raw)
In-Reply-To: <CAGDYbUPbY7MFcntGwTdxikxXahccKQTASApYGz=wPPksGMWJVg@mail.gmail.com>
References: <4405957b-2e0f-bfc5-eaf6-5e2864da2796@gmail.com>
	<CAGDYbUM0Lv-fcFp_Mh4jyBtSrW24Z1psvey6FBi5q=LQx=7CMQ@mail.gmail.com>
	<9884a24a-c129-a1a9-1901-2a9c8987331e@gmail.com>
	<CAGDYbUPbY7MFcntGwTdxikxXahccKQTASApYGz=wPPksGMWJVg@mail.gmail.com>

That won't work, because that would catch any query on a table which happens 
to have the string "select" in a table, index or column name.

On 06/11/2018 09:53 AM, Shreeyansh Dba wrote:
> Hi Ron,
>
> You can use LIKE  operator to get only select query and specify LIMIT as 
> per your requirement.
>
> Hope this helps..
>
> <http://www.shreeyansh.com;
>
> On Mon, Jun 11, 2018 at 7:26 PM, Ron <ronljohnsonjr@gmail.com 
> <mailto:ronljohnsonjr@gmail.com>> wrote:
>
>     Thanks.
>
>     How, then, do I get only long-running SELECT statements?
>
>     ​​
>     I've tried this (since I don't want to inadvertently get other DML &
>     DDL statements
>     ​​
>     which might have "select" in a field name), but CTEs and queries that
>     start with a comment slip by this filter.
>
>     FROM pg_stat_activity
>     WHERE state <> 'idle'
>       AND SUBSTRING(UPPER(query) FROM 1 FOR 6) = 'SELECT';
>
>     Thanks
>
>
>     On 06/11/2018 08:47 AM, Shreeyansh Dba wrote:
>>     Ron,
>>
>>     Yes, It can list the insert,delete and update statement as well..
>>
>>     <http://www.shreeyansh.com;
>>
>>     On Mon, Jun 11, 2018 at 7:07 PM, Ron <ronljohnsonjr@gmail.com
>>     <mailto:ronljohnsonjr@gmail.com>> wrote:
>>
>>         Hi,
>>
>>         Does pg_stat_activity only list SELECT statements, or does it
>>         also list INSERT, DELETE and UPDATE statements?
>>
>>
>
>     -- 
>     Angular momentum makes the world go 'round.
>
>

-- 
Angular momentum makes the world go 'round.

view thread (23+ messages)  latest in thread

Message-ID: <211b19ea-18dc-6897-3c53-8d994550cd15@gmail.com>
Permalink:  ../211b19ea-18dc-6897-3c53-8d994550cd15@gmail.com/
Also on:    postgresql.org/message-id/211b19ea-18dc-6897-3c53-8d994550cd15@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: pg_stat_activity
  In-Reply-To: <211b19ea-18dc-6897-3c53-8d994550cd15@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox