Re: Logging queries executed by SPI_execute - Mailing list pgsql-general

From Marcelo Fernandes
Subject Re: Logging queries executed by SPI_execute
Date
Msg-id CAM2F1VPz8qw2S-ND1xHWqaDw+wZ6cpeXErsONYCJLob=mc_Rqg@mail.gmail.com
Whole thread Raw
In response to Re: Logging queries executed by SPI_execute  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general
On Mon, Feb 3, 2025 at 6:46 PM Pavel Stehule <pavel.stehule@gmail.com> 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



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: could not accept ssl connection tlsv1 alert iso-8859-1 ca
Next
From: Rich Shepard
Date:
Subject: Lookup tables