Обсуждение: pg_stat_statements doesn't track commit from pl/pgsql blocks

Поиск
Список
Период
Сортировка

pg_stat_statements doesn't track commit from pl/pgsql blocks

От
legrand legrand
Дата:
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;

...

I don't know how difficult it would be to fix it,
but this could help in trouble shouting.

Regards
PAscal



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html


Re: pg_stat_statements doesn't track commit from pl/pgsql blocks

От
Bruce Momjian
Дата:
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 +


RE: pg_stat_statements doesn't track commit from pl/pgsql blocks

От
legrand legrand
Дата:

forgot to cc pgsql-general list


De : legrand legrand <legrand_legrand@hotmail.com>
Envoyé : vendredi 22 février 2019 20:26
À : Bruce Momjian
Objet : RE: pg_stat_statements doesn't track commit from pl/pgsql blocks
 
Hello Bruce,

thank you for taking time to answer.
yes, I was expecting something like

        SELECT calls,query FROM pg_stat_statements;
         calls |               query
        -------+-----------------------------------
             1 | select pg_stat_statements_reset()
             1 | do $$ begin commit; end $$
             1 | commit

as I didn't found any other place to track this 'commit' information.

nb: I don't "want" anything this is just an open question,
and I'm perfectly able to ear that its not expected or not easy to implement.

Regards
PAscal