Re: pg_stat_activity

From: Pavan Teja <pavan(dot)postgresdba(at)gmail(dot)com>
To: Rui DeSousa <rui(dot)desousa(at)icloud(dot)com>
Cc: Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: pg_stat_activity
Date: 2018-06-11 17:07:05
Message-ID: CACh9nsZBYxBrgfFtK-KPB4x-8vZi83Sx=Qzbgf4cpVg+M2SDJA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Mon, Jun 11, 2018, 9:58 PM Rui DeSousa <rui(dot)desousa(at)icloud(dot)com> wrote:

>
> > On Jun 11, 2018, at 9:56 AM, Ron <ronljohnsonjr(at)gmail(dot)com> wrote:
> >
> > How, then, do I get only long-running SELECT statements?
> >
>
> Why only select statements? What about select statements that are really
> updates?
>
> i.e.
>
> select …. for update;
> select do_some_work(); —In this case you will not see the actual
> executing SQL in the function which could be update, delete, select, etc.
>
> Or what about delete or update with returning?
>

Hi Ron,

You can use LIKE operator for getting updates and deletes and inserts like

" Select * from pg_stat_activity where query like '%UPDATE%' or '%update%' "

The same in case of updates and deletes. You can also configure table
level audit with the help of triggers to capture DML's

Hope this helps.

Thanks & Regards,
Pavan.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2018-06-11 17:13:37 Re: pg_stat_activity
Previous Message Peter Geoghegan 2018-06-11 17:02:39 Re: PostgreSQL 'Corruption & Fragmentation' detection and resolution/fix