From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Manoj Kumar <manojkumar(at)temenos(dot)com> |
Cc: | "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: PostgreSQL blocked locks query |
Date: | 2021-05-13 20:09:25 |
Message-ID: | 20210513200925.GL27406@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Thu, May 13, 2021 at 01:54:32PM +0000, Manoj Kumar wrote:
> I have query in terms of lock monitoring in PostgreSQL where I am not able to find a way to figure out what value has been passed in SQL statement (from JDBC driver as prepared statement).
>
> I am using PostgreSQL 13 version.
>
> The following is the SQL statement I am running in PGAdmin
>
> The output I am getting is below, where in the SQL query is with $1.
>
> [cid:image001(dot)png(at)01D74810(dot)4207C100]
>
> Is there a way to compute what is being passed as value for the above SQL statement ?
You should enable query logging, and pull the params out of the log.
Note that v13 has log_parameter_max_length, which defaults to showing params in
full.
[pryzbyj(at)telsasoft2019 ~]$ PGOPTIONS='-c log_min_duration_statement=0 -c client_min_messages=debug' python3 -c "import pg; db=pg.DB('postgres'); q=db.query('SELECT \$1', 1)"
DEBUG: loaded library "auto_explain"
DEBUG: parse <unnamed>: SELECT $1
LOG: duration: 0.230 ms parse <unnamed>: SELECT $1
DEBUG: bind <unnamed> to <unnamed>
LOG: duration: 0.141 ms bind <unnamed>: SELECT $1
DETAIL: parameters: $1 = '1'
LOG: duration: 0.029 ms execute <unnamed>: SELECT $1
DETAIL: parameters: $1 = '1'
--
Justin
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2021-05-13 23:52:33 | Re: BUG #16968: Planner does not recognize optimization |
Previous Message | Manoj Kumar | 2021-05-13 13:54:32 | PostgreSQL blocked locks query |