[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: Logging the query executed on the server
From:       Steve Baldwin <steve.baldwin () gmail ! com>
Date:       2022-07-24 7:13:49
Message-ID: CAKE1Aia0o=y1XLFJYkkEeT_EW35eN8uPqLVCjMzOp=M=C-0p_g () mail ! gmail ! com
[Download RAW message or body]

On Sun, Jul 24, 2022 at 4:29 PM Igor Korot <ikorot01@gmail.com> wrote:

>
> 2 things:
> 1. How do I turn this off? ;-)
>

When you change the setting via 'set', that change is only for the current
session. You can revert it with 'set {some param} to default;' or just
terminate the session. If you want to make the change permanent, you need
to set it in the config file.

2. The log does show the query but it shows it with the placeholders.
> Is there a way to see the actual query?
>

Not sure what you mean here. The query shown in the log should be what is
actually executed by the server. If you are using placeholders, there are
probably 3 different log entries - one for the parse step, one for the bind
step and one for the execute step. If you are asking what are the bind
variable values, they are shown in the bind step. For example:

2022-07-24 07:00:00
UTC:10.122.33.196(33732):b2bc_api@b2bcreditonline:[7786]:LOG:
duration: 0.072 ms bind <unnamed>:
select public.currency_on_mismatch() as on_mismatch,
set_config('search_path', $1, true),
set_config('application.user_id', $2, true),
set_config('application.app_client', $3, true),
set_config('application.api_client_id', $4 , true),
set_config('application.source', $5 , true),
set_config('application.request_id', $6 , true),
set_config('application.in_test_context', $7, true),
set_config('lock_timeout', $8, true),
txid_current()
2022-07-24 07:00:00
UTC:10.122.33.196(33732):b2bc_api@b2bcreditonline:[7786]:DETAIL:
parameters: $1 = 'public', $2 = 'Admin/Support', $3 = 'Admin/Support', $4 =
'ce34e2bc-2c65-4fc1-9b95-878aef19a348', $5 = '?', $6 =
'4432dbb2-ab1c-4bd8-a413-ff5c704209a6', $7 = 'f', $8 = '10s'

If this doesn't help, maybe post what you're seeing in the log.

Cheers,

Steve

[Attachment #3 (text/html)]

<div dir="ltr"><div dir="ltr">On Sun, Jul 24, 2022 at 4:29 PM Igor Korot &lt;<a \
href="mailto:ikorot01@gmail.com">ikorot01@gmail.com</a>&gt; wrote:<br></div><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br> 2 things:<br>
1. How do I turn this off? ;-)<br></blockquote><div><br></div><div>When you change \
the setting via &#39;set&#39;, that change is only for the current session. You can \
revert it with &#39;set {some param} to default;&#39; or just terminate the session. \
If you want to make the change permanent, you need to set it in the config \
file.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> 2. The log does show \
the query but it shows it with the placeholders.<br> Is there a way to see the actual \
query?<br></blockquote><div><br></div><div>Not sure what you mean here. The query \
shown in the log should be what is actually executed by the server. If you are using \
placeholders, there are probably 3 different log entries - one for the parse step, \
one for the bind step and one for the execute step. If you are asking what are the \
bind variable values, they are shown in the bind step. For \
example:</div><div><br></div><div>2022-07-24 07:00:00 \
UTC:10.122.33.196(33732):b2bc_api@b2bcreditonline:[7786]:LOG: duration: 0.072 ms bind \
&lt;unnamed&gt;:<br>select public.currency_on_mismatch() as \
on_mismatch,<br>set_config(&#39;search_path&#39;, $1, \
true),<br>set_config(&#39;application.user_id&#39;, $2, \
true),<br>set_config(&#39;application.app_client&#39;, $3, \
true),<br>set_config(&#39;application.api_client_id&#39;, $4 , \
true),<br>set_config(&#39;application.source&#39;, $5 , \
true),<br>set_config(&#39;application.request_id&#39;, $6 , \
true),<br>set_config(&#39;application.in_test_context&#39;, $7, \
true),<br>set_config(&#39;lock_timeout&#39;, $8, \
true),<br>txid_current()<br>2022-07-24 07:00:00 \
UTC:10.122.33.196(33732):b2bc_api@b2bcreditonline:[7786]:DETAIL: parameters: $1 = \
&#39;public&#39;, $2 = &#39;Admin/Support&#39;, $3 = &#39;Admin/Support&#39;, $4 = \
&#39;ce34e2bc-2c65-4fc1-9b95-878aef19a348&#39;, $5 = &#39;?&#39;, $6 = \
&#39;4432dbb2-ab1c-4bd8-a413-ff5c704209a6&#39;, $7 = &#39;f&#39;, $8 = \
&#39;10s&#39;<br></div><div><br></div><div>If this doesn&#39;t help, maybe post what \
you&#39;re seeing in the \
log.</div><div><br></div><div>Cheers,</div><div><br></div><div>Steve</div></div></div>




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic