pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedCurrent query of the PL/pgsql procedure.
7+ messages / 6 participants
[nested] [flat]
* Current query of the PL/pgsql procedure.
@ 2013-12-15 16:18 Yuri Levinsky <yuril@celltick.com>
0 siblings, 3 replies; 7+ messages in thread
From: Yuri Levinsky @ 2013-12-15 16:18 UTC (permalink / raw)
To: pgsql-performance
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.
Sincerely yours,
[Description: Celltick logo_highres]
Yuri Levinsky, DBA
Celltick Technologies Ltd., 32 Maskit St., Herzliya 46733, Israel
Mobile: +972 54 6107703, Office: +972 9 9710239; Fax: +972 9 9710222
Attachments:
image003.jpg (image/jpeg, 2.2K) download
view image
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Current query of the PL/pgsql procedure.
@ 2013-12-15 18:05 Craig James <cjames@emolecules.com>
parent: Yuri Levinsky <yuril@celltick.com>
2 siblings, 0 replies; 7+ messages in thread
From: Craig James @ 2013-12-15 18:05 UTC (permalink / raw)
To: Yuri Levinsky <yuril@celltick.com>; +Cc: pgsql-performance
On Sun, Dec 15, 2013 at 8:18 AM, 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.
>
pg_stat_activity is the right table, but you have to be the super-user to
see queries by others. Here's what I use:
$ psql -U postgres
postgres=# select procpid, datname, usename, current_query from
pg_stat_activity where current_query !~ '<IDLE>';
Craig
>
> *Sincerely yours*,
>
>
>
> [image: Description: Celltick logo_highres]
>
> Yuri Levinsky, DBA
>
> Celltick Technologies Ltd., 32 Maskit St., Herzliya 46733, Israel
>
> Mobile: +972 54 6107703, Office: +972 9 9710239; Fax: +972 9 9710222
>
>
>
Attachments:
image003.jpg (image/jpeg, 2.2K) download
view image
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Current query of the PL/pgsql procedure.
@ 2013-12-16 10:26 hubert depesz lubaczewski <depesz@depesz.com>
parent: Yuri Levinsky <yuril@celltick.com>
2 siblings, 2 replies; 7+ messages in thread
From: hubert depesz lubaczewski @ 2013-12-16 10:26 UTC (permalink / raw)
To: Yuri Levinsky <yuril@celltick.com>; +Cc: pgsql-performance
On Sun, Dec 15, 2013 at 04:18:18PM +0000, Yuri Levinsky 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.
pg_stat_activity and pg logs, can't see what your function does
internally.
What you can do, though, is to add some "RAISE LOG" to the function, so
that it will log its progress.
Check this for example:
http://www.depesz.com/2010/03/18/profiling-stored-proceduresfunctions/
Best regards,
depesz
Attachments:
signature.asc (application/pgp-signature, 800B) download
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Current query of the PL/pgsql procedure.
@ 2013-12-16 11:42 Yuri Levinsky <yuril@celltick.com>
parent: hubert depesz lubaczewski <depesz@depesz.com>
1 sibling, 1 reply; 7+ messages in thread
From: Yuri Levinsky @ 2013-12-16 11:42 UTC (permalink / raw)
To: depesz@depesz.com <depesz@depesz.com>; pgsql-performance; +Cc: Craig James <cjames@emolecules.com>
Dear Depesz,
This is very problematic solution: I have to change whole!!! my code to put appropriate comment with query text before any query execution. In addition I would like to know current execution plan, that seems to be impossible. This is very hard limitation let's say. In case of production issue I'll just unable to do it: the issue already happening, I can't stop procedure and start code change.
James,
I saw your reply: I see the function is running, it's just not clear that exactly and how this function doing.
Sincerely yours,
Yuri Levinsky, DBA
Celltick Technologies Ltd., 32 Maskit St., Herzliya 46733, Israel
Mobile: +972 54 6107703, Office: +972 9 9710239; Fax: +972 9 9710222
-----Original Message-----
From: depesz@depesz.com [mailto:depesz@depesz.com]
Sent: Monday, December 16, 2013 12:26 PM
To: Yuri Levinsky
Cc: pgsql-performance@postgresql.org
Subject: Re: [PERFORM] Current query of the PL/pgsql procedure.
On Sun, Dec 15, 2013 at 04:18:18PM +0000, Yuri Levinsky 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.
pg_stat_activity and pg logs, can't see what your function does internally.
What you can do, though, is to add some "RAISE LOG" to the function, so that it will log its progress.
Check this for example:
http://www.depesz.com/2010/03/18/profiling-stored-proceduresfunctions/
Best regards,
depesz
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Current query of the PL/pgsql procedure.
@ 2013-12-16 12:47 Matheus de Oliveira <matioli.matheus@gmail.com>
parent: Yuri Levinsky <yuril@celltick.com>
2 siblings, 0 replies; 7+ messages in thread
From: Matheus de Oliveira @ 2013-12-16 12:47 UTC (permalink / raw)
To: Yuri Levinsky <yuril@celltick.com>; +Cc: 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).
[1] http://www.postgresql.org/docs/current/static/auto-explain.html
[2] http://www.postgresql.org/docs/current/static/pgstatstatements.html
Best regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nĂvel F!
www.dextra.com.br/postgres
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Current query of the PL/pgsql procedure.
@ 2013-12-16 13:29 Andrew Dunstan <andrew@dunslane.net>
parent: hubert depesz lubaczewski <depesz@depesz.com>
1 sibling, 0 replies; 7+ messages in thread
From: Andrew Dunstan @ 2013-12-16 13:29 UTC (permalink / raw)
To: depesz@depesz.com; +Cc: Yuri Levinsky <yuril@celltick.com>; pgsql-performance
On 12/16/2013 05:26 AM, hubert depesz lubaczewski wrote:
> On Sun, Dec 15, 2013 at 04:18:18PM +0000, Yuri Levinsky 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.
> pg_stat_activity and pg logs, can't see what your function does
> internally.
>
> What you can do, though, is to add some "RAISE LOG" to the function, so
> that it will log its progress.
>
> Check this for example:
> http://www.depesz.com/2010/03/18/profiling-stored-proceduresfunctions/
>
Also, the auto-explain module can peer inside functions. See
<http://www.postgresql.org/docs/current/static/auto-explain.html;
cheers
andrew
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Current query of the PL/pgsql procedure.
@ 2013-12-18 08:30 Guillaume Lelarge <guillaume@lelarge.info>
parent: Yuri Levinsky <yuril@celltick.com>
0 siblings, 0 replies; 7+ messages in thread
From: Guillaume Lelarge @ 2013-12-18 08:30 UTC (permalink / raw)
To: Yuri Levinsky <yuril@celltick.com>; +Cc: depesz@depesz.com <depesz@depesz.com>; pgsql-performance; Craig James <cjames@emolecules.com>
On Mon, 2013-12-16 at 11:42 +0000, Yuri Levinsky wrote:
> Dear Depesz,
> This is very problematic solution: I have to change whole!!! my code to put appropriate comment with query text before any query execution. In addition I would like to know current execution plan, that seems to be impossible. This is very hard limitation let's say. In case of production issue I'll just unable to do it: the issue already happening, I can't stop procedure and start code change.
> James,
> I saw your reply: I see the function is running, it's just not clear that exactly and how this function doing.
>
This blog post
(http://blog.guillaume.lelarge.info/index.php/post/2012/03/31/Profiling-PL/pgsql-functions) can probably help you profiling your PL/pgsql functions without modifying them.
I'm interested in any comments you can have on the log_functions hook
function.
Regards.
--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2013-12-18 08:30 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-12-15 16:18 Current query of the PL/pgsql procedure. Yuri Levinsky <yuril@celltick.com>
2013-12-15 18:05 ` Craig James <cjames@emolecules.com>
2013-12-16 10:26 ` hubert depesz lubaczewski <depesz@depesz.com>
2013-12-16 11:42 ` Yuri Levinsky <yuril@celltick.com>
2013-12-18 08:30 ` Guillaume Lelarge <guillaume@lelarge.info>
2013-12-16 13:29 ` Andrew Dunstan <andrew@dunslane.net>
2013-12-16 12:47 ` Matheus de Oliveira <matioli.matheus@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox