Currently running queries with actual arguments?

Started by rihadover 4 years ago4 messagesgeneral
Jump to latest
#1rihad
rihad@mail.ru

Hi, is it possible to view the list of currently running queries with
$1, $2 etc replaced with the actual arguments?

#2Garfield Lewis
garfield.lewis@lzlabs.com
In reply to: rihad (#1)
Re: Currently running queries with actual arguments?

The way I normally get this info is by setting the following:

log_statement = 'all'

then the arguments will be printed in the postgres.log file. There could be some other way but that is what I know.

--
Regards,
Garfield

On 2021-09-23, 11:33 AM, "rihad" <rihad@mail.ru> wrote:

Hi, is it possible to view the list of currently running queries with
$1, $2 etc replaced with the actual arguments?

#3rihad
rihad@mail.ru
In reply to: Garfield Lewis (#2)
Re: Currently running queries with actual arguments?

On 9/23/21 7:58 PM, Garfield Lewis wrote:

The way I normally get this info is by setting the following:

log_statement = 'all'

then the arguments will be printed in the postgres.log file. There could be some other way but that is what I know.

Thanks, those queries are logged after their completion, but I
specifically need the list of unfinished long queries currently being
executed.

#4Bruce Momjian
bruce@momjian.us
In reply to: rihad (#3)
Re: Currently running queries with actual arguments?

On Thu, Sep 23, 2021 at 08:51:49PM +0400, rihad wrote:

On 9/23/21 7:58 PM, Garfield Lewis wrote:

The way I normally get this info is by setting the following:

log_statement = 'all'

then the arguments will be printed in the postgres.log file. There could be some other way but that is what I know.

Thanks, those queries are logged after their completion, but I specifically
need the list of unfinished long queries currently being executed.

Uh, log_statement prints them before they are executed ---
log_min_duration_statment prints them after execution. You can verify
this by running:

SET log_statement = 'all';
SELECT pg_sleep(430);

and then looking in the log file.

--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com

If only the physical world exists, free will is an illusion.