Re: Current query of the PL/pgsql procedure.

Поиск
Список
Период
Сортировка
От Matheus de Oliveira
Тема Re: Current query of the PL/pgsql procedure.
Дата
Msg-id CAJghg4KUFm07QYWieDE8B4YmqXHiM3DTp7kis-ELcP4R0Z4Gng@mail.gmail.com
обсуждение исходный текст
Ответ на Current query of the PL/pgsql procedure.  (Yuri Levinsky <yuril@celltick.com>)
Список pgsql-performance

On Sun, Dec 15, 2013 at 2:18 PM, Yuri Levinsky <yuril@celltick.com> wrote:

Dear ALL,

I am running PL/pgsql procedure with sql statements that taking a long time. I able to see them in the log just after their completion. How can I see currently running SQL statement?  I am able to see in pg_stat_activity only my call to function. Many thanks in advance.

 




As noticed, pg_stat_activity will only be able to see the call to that function, not the queries been executed inside the function itself. The same will happen with the logs (configuring GUCs like log_statements or log_min_duration_statement). A solution I have used to solve this issue is either the contrib auto_explain [1] or pg_stat_statements [2]. Both will be able to get the queries executed inside the functions. For that, you will have to configure then (by default they will not track the queries inside):

* for auto_explain: `auto_explain.log_nested_statements = on`
* for pg_stat_statements: `pg_stat_statements.track = all`

The problem you stated about the logs, that it only logs after the execution not during or before, will still remain. Both will "get the query" right after the execution. In your use case auto_explain seems better to use to track, as it can grows with no limit (you will have to control your log file size and auto_explain.log_min_duration to avoid a log flood, though).
 

Best regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres

В списке pgsql-performance по дате отправления:

Предыдущее
От: Yuri Levinsky
Дата:
Сообщение: Re: Current query of the PL/pgsql procedure.
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Current query of the PL/pgsql procedure.