Re: pg_stat_activity

From: Shreeyansh Dba <shreeyansh2014(at)gmail(dot)com>
To: Ron <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: pg_stat_activity
Date: 2018-06-11 14:53:38
Message-ID: CAGDYbUPbY7MFcntGwTdxikxXahccKQTASApYGz=wPPksGMWJVg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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(at)gmail(dot)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(at)gmail(dot)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.
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ron 2018-06-11 15:07:49 Re: pg_stat_activity
Previous Message Debraj Manna 2018-06-11 14:32:32 Removing WALS when replication slot is not busy