public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Logging queries executed by SPI_execute
2+ messages / 2 participants
[nested] [flat]

* Re: Logging queries executed by SPI_execute
@ 2025-02-04 04:08 Marcelo Fernandes <[email protected]>
  2025-02-04 05:06 ` Re: Logging queries executed by SPI_execute Pavel Stehule <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Marcelo Fernandes @ 2025-02-04 04:08 UTC (permalink / raw)
  To: Pavel Stehule <[email protected]>; +Cc: [email protected]

On Mon, Feb 3, 2025 at 6:46 PM Pavel Stehule <[email protected]> wrote:
> The queries executed by SPI are never executed on the top level. These queries are marked as nested.
>
> So you need to use auto_explain https://www.postgresql.org/docs/current/auto-explain.html with active auto_explain.log_nested_statements

Thanks Pavel, I have tried that but however couldn't succeed.

I have added this to my postgres.conf file:

    session_preload_libraries = 'auto_explain'
    auto_explain.log_nested_statements = true

After running pg_repack, which calls SPI_execute* functions, I can't really see
those functions being propagated to the logs.

I have a workaround in place, which is to add elog calls such as

    elog(LOG, "...")

to capture the queries. But of course, ideally a postgres.conf setting would be
more handy.

Best,
Marcelo






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Logging queries executed by SPI_execute
  2025-02-04 04:08 Re: Logging queries executed by SPI_execute Marcelo Fernandes <[email protected]>
@ 2025-02-04 05:06 ` Pavel Stehule <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Pavel Stehule @ 2025-02-04 05:06 UTC (permalink / raw)
  To: Marcelo Fernandes <[email protected]>; +Cc: [email protected]

út 4. 2. 2025 v 5:09 odesílatel Marcelo Fernandes <[email protected]>
napsal:

> On Mon, Feb 3, 2025 at 6:46 PM Pavel Stehule <[email protected]>
> wrote:
> > The queries executed by SPI are never executed on the top level. These
> queries are marked as nested.
> >
> > So you need to use auto_explain
> https://www.postgresql.org/docs/current/auto-explain.html with active
> auto_explain.log_nested_statements
>
> Thanks Pavel, I have tried that but however couldn't succeed.
>
> I have added this to my postgres.conf file:
>
>     session_preload_libraries = 'auto_explain'
>     auto_explain.log_nested_statements = true
>

you are missing setting  auto_explain.log_min_duration

>
> After running pg_repack, which calls SPI_execute* functions, I can't
> really see
> those functions being propagated to the logs.
>
> I have a workaround in place, which is to add elog calls such as
>
>     elog(LOG, "...")
>
> to capture the queries. But of course, ideally a postgres.conf setting
> would be
> more handy.
>
> Best,
> Marcelo
>


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-02-04 05:06 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-02-04 04:08 Re: Logging queries executed by SPI_execute Marcelo Fernandes <[email protected]>
2025-02-04 05:06 ` Pavel Stehule <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox