Re: pg_stat_statements doesn't track commit from pl/pgsql blocks - Mailing list pgsql-general

From Bruce Momjian
Subject Re: pg_stat_statements doesn't track commit from pl/pgsql blocks
Date
Msg-id 20190222020052.4wjwtt3qdyp4rh6f@momjian.us
Whole thread Raw
In response to pg_stat_statements doesn't track commit from pl/pgsql blocks  (legrand legrand <legrand_legrand@hotmail.com>)
List pgsql-general
On Sun, Feb 17, 2019 at 02:52:07PM -0700, legrand legrand wrote:
> Hello,
> 
> It seems that pgss doesn't track commit (nor rollback) commands from
> pl/pgsql blocks.
> using psql in version 11.1:
> 
> select pg_stat_statements_reset();
> do $$ begin commit; end $$;
> select calls,query from pg_stat_statements;

Uh, can you show me exactly what you were hoping to see?  I see:

    CREATE EXTENSION pg_stat_statements;
    
    SELECT pg_stat_statements_reset();
     pg_stat_statements_reset
    --------------------------
    
    DO $$ BEGIN COMMIT; END $$;
    
    SELECT calls,query FROM pg_stat_statements;
     calls |               query
    -------+-----------------------------------
         1 | select pg_stat_statements_reset()
         1 | do $$ begin commit; end $$

You wanted to see the 'commit'?  That is not a client-supplied command
and is not tracked, and I am not sure we would want to do that.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +


pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: Copy entire schema A to a different schema B
Next
From: Bruce Momjian
Date:
Subject: Re: PG Upgrade with hardlinks, when to start/stop master and replicas