Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tfB9t-000Dsd-Tk for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 05:07:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tfB9s-001HAN-FJ for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 05:07:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tfB9s-001HAE-4K for pgsql-general@lists.postgresql.org; Tue, 04 Feb 2025 05:07:36 +0000 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tfB9o-003A3G-3D for pgsql-general@lists.postgresql.org; Tue, 04 Feb 2025 05:07:35 +0000 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-6f8c58229f1so35148867b3.0 for ; Mon, 03 Feb 2025 21:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738645651; x=1739250451; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=y/Bym1WmuvIQrE813JXOHYuLYLw2+TRr+dFqfS9uGiI=; b=UG4s2ArkIXArM7SIFemrZuneXbSgLvwX6Gvi1UipNcKr1H9uoVM+xHOCq99y2/IhPQ hmopJrnYguYeRcJBwhEYSNf64hkFbYTFd3rVBfZYO2jvMi1aORLryEkh6FgXsBnUtnq0 dGcIjQQ7yXpIxGR1EKVh/kN1skLr51Brmeu4sG4jPIlVuuq0mokFIytn7Vjzd7Lo318y 7Kz/ZQV0zhMZwKAa1xIAKgLL79ezKLPpyvU2Ob/f04t9ACx8l+veQn7ebsX0qMS5BrFz SxeubltJNwduLz6jzeUvSrazWmKly9tONUg7/9507LvfDpBryKaUEkIZwvoOht9IHTJ+ GArA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738645651; x=1739250451; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y/Bym1WmuvIQrE813JXOHYuLYLw2+TRr+dFqfS9uGiI=; b=OZRBroa6CKEqHd9F6Gj2raFSCRPbmk7SxLu7iASosfXEmYGSYHFT0KuW9PwE6jA6+n mTzA3Iqs1I0jjiPCKYXQKbg7ol3G9h5surwsKqDKQzFlYa9dTwEkGsHTWe9iERz2l0v9 CuZS950wVJ9+ifVqxntiBm8a5xDDusiG9bqksdZ2hkihqNTwA03o/z6AL3T8Dv47hlXF ccNw292xpi5wnXF3xpDOUMnYh94Gpvz5n4DBcD17zgiTsfiEd6w3iNbVwXnA4GikjzYB 6mJ7cNHjP1rmrdv64dQvstp9aY1tmni1yJCPy/FI5JNj54TizrPRrP5ATPzHXcFedOCL egWQ== X-Gm-Message-State: AOJu0YzCGeG+1J50oagrD/wR98AbDGv35JLc3xIKablLn99OJRRqVTPU EnMsbc5OVuHLNq6CHoG4H5EhNFthRH6xEQ61EKGtNMYhEaE/Yfzw/D2XSKoCMWj+jjPnoND4OXJ mcLxal9o6hfWI/NED8/GvbEQ3XtY= X-Gm-Gg: ASbGncsskjo83oUAdFc0weNgE+VyOUJsP7bo8Z3XxAPcxKECIXWRKpctYhcEochX6kY TMn6InkFcR3XGG0BD5QHXW0tvOuWCH7tU4zcBVyrm/RjedxV9bdedLrkUkavQWBY7wQOXOkt4BA 2jfM5O2gwfiDF1h7yEXxOb031cg9YmOw== X-Google-Smtp-Source: AGHT+IHBNC85i4FbhpXCtsHcTzArB3m1i50RLNDuaNpaEU2O8oFPt6GipwSxWCvdKS7FQFiA/tJj41gveN0dNWzTu7Q= X-Received: by 2002:a05:690c:6010:b0:6dd:b8ff:c29c with SMTP id 00721157ae682-6f9775bb54amr16828367b3.17.1738645651553; Mon, 03 Feb 2025 21:07:31 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Stehule Date: Tue, 4 Feb 2025 06:06:55 +0100 X-Gm-Features: AWEUYZkLgTEKgCqf_ixl7Lk30dcYNILYK_e5suK1qH39ca46rIeoVWIgbzb5DAo Message-ID: Subject: Re: Logging queries executed by SPI_execute To: Marcelo Fernandes Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000007385e2062d49fc26" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000007385e2062d49fc26 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =C3=BAt 4. 2. 2025 v 5:09 odes=C3=ADlatel Marcelo Fernandes napsal: > On Mon, Feb 3, 2025 at 6:46=E2=80=AFPM Pavel Stehule > 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 =3D 'auto_explain' > auto_explain.log_nested_statements =3D 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 > --0000000000007385e2062d49fc26 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=C3=BAt 4. 2. 2= 025 v=C2=A05:09 odes=C3=ADlatel Marcelo Fernandes <marcefern7@gmail.com> napsal:
On Mon, Feb 3, 2025 at 6:46=E2=80= =AFPM 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_ex= plain.log_nested_statements

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

I have added this to my postgres.conf file:

=C2=A0 =C2=A0 session_preload_libraries =3D 'auto_explain'
=C2=A0 =C2=A0 auto_explain.log_nested_statements =3D true
<= div>
you are missing setting=C2=A0 auto_explain.log_min_duration =

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

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

=C2=A0 =C2=A0 elog(LOG, "...")

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

Best,
Marcelo
--0000000000007385e2062d49fc26--