What query currently running within function

Started by Rebecca Clarkeover 11 years ago4 messagesgeneral
Jump to latest
#1Rebecca Clarke
r.clarke83@gmail.com

Hi all,

Presently I'm executing a function that runs many queries within it.

select * from _myfunction();

Is there a way to see what query it is up to within the function?
When I do a select of pg_stat_activity it just shows me the _myfunction()
query.

I'm running postgresql 9.1

Thanks in advance.

#2Guillaume Lelarge
guillaume@lelarge.info
In reply to: Rebecca Clarke (#1)
Re: What query currently running within function

Hi,

2014-07-22 11:36 GMT+02:00 Rebecca Clarke <r.clarke83@gmail.com>:

Hi all,

Presently I'm executing a function that runs many queries within it.

select * from _myfunction();

Is there a way to see what query it is up to within the function?

Unfortunately, no. Even with the latest release. pg_stat_activity shows you
what the client fires, not what the server does.

When I do a select of pg_stat_activity it just shows me the _myfunction()
query.

I'm running postgresql 9.1

Thanks in advance.

--
Guillaume.
http://blog.guillaume.lelarge.info
http://www.dalibo.com

In reply to: Guillaume Lelarge (#2)
Re: What query currently running within function

On Tue, Jul 22, 2014 at 2:45 AM, Guillaume Lelarge
<guillaume@lelarge.info> wrote:

Unfortunately, no. Even with the latest release. pg_stat_activity shows you
what the client fires, not what the server does.

pg_stat_statements has a "track" GUC which controls whether or not
nested statements, such as statements executed within functions are
tracked.

--
Regards,
Peter Geoghegan

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Merlin Moncure
mmoncure@gmail.com
In reply to: Rebecca Clarke (#1)
Re: What query currently running within function

On Tue, Jul 22, 2014 at 4:36 AM, Rebecca Clarke <r.clarke83@gmail.com> wrote:

Hi all,

Presently I'm executing a function that runs many queries within it.

select * from _myfunction();

Is there a way to see what query it is up to within the function?
When I do a select of pg_stat_activity it just shows me the _myfunction()
query.

I'm running postgresql 9.1

Thanks in advance.

raise notices or warnings in the log. if the function is sql and
not pl/pgsql, you can wrap the RAISE feature.

merlin

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general