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 1tfAFH-0007FZ-Fu for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 04:09:07 +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 1tfAFF-0011Y8-3J for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 04:09:05 +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 1tfAFE-0011Y0-Mh for pgsql-general@lists.postgresql.org; Tue, 04 Feb 2025 04:09:04 +0000 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tfAFB-0039hF-0t for pgsql-general@lists.postgresql.org; Tue, 04 Feb 2025 04:09:04 +0000 Received: by mail-io1-xd44.google.com with SMTP id ca18e2360f4ac-84cdb6fba9bso405788039f.2 for ; Mon, 03 Feb 2025 20:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738642139; x=1739246939; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=h8nAHE2bqmCnQgY8h+/NqtqDJ3WHkwZ/9D0mtR8VG2A=; b=jueY7EuodzY4YpSSXjJGpnUMc7wqrHH7YMnmbMyKoKBTmcclRwqCfW4J0EuJemMY2N iHUF3fba37svm9qPbj0Oub8yYv/rdRk4tsn2ftPDPBtG1Xsfso3LVI1/g+H17SopC5ec g1Fu7/zp3mTHPeeXwaUDtWezwBz2jm8k4j1NtnvsBgJ7jcv8HZoShO7anmgbHwVCgYII WtJEqFGpAy6254PLHLZ5wzFTblJRm/BObSiV83g6dWAIl4g8HaLbDYGjYVquJQQgGyv/ /q9JEDfVulI3IQ60+FNsSPLzhGoGvZ+TW0M1BCb79OKgOhd4VcYFhhtauC2qEPMVM2KF bdrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738642139; x=1739246939; h=content-transfer-encoding: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=h8nAHE2bqmCnQgY8h+/NqtqDJ3WHkwZ/9D0mtR8VG2A=; b=Fz/UglnxHgRRs4asBM4CaX+5CzDQ4r2yAlc9idCj3LRxmGpP66gMGwd+64qQaKBBMU NMsn0Tx4mX2PJOoaodH9EzAEBeDktbWyxrrUH4LNnEiJzzKJykudlsdUFj10GgijKJ+l Wi800ldQAY1zjaljuBj9vPFYWIsha9IGXpxLEYIdDetGG2AunXeWTgPLhU4YNZJ3wEBe x6qubVzgDxUaIQwqpvQhklvclZDWXSTa51Wye2kpOVwJAUO87kwNbceOGG+TrydXe8tg MQ0X2nT4IPsVBm4EBFgVTgD04+UKSuz2Rjn476PGww0emWudvDeHEcw4Db8Nd9BCyp3I wBEw== X-Gm-Message-State: AOJu0Yz+S0ORyT46JJY3YZJ0B7DMXvO/Ci5mb+JvY4xo58t1p1TQO5Yt 52oDmeTH1hrxxocEq43tN0oTm1d+ryFOU4Pv09ckY0nVvV7pnXR7KglFNCQ3817dxEnSjGwO5U/ Wp1uE/3ux3s1k7KQdACrsxBz1TmZQbwq9E80= X-Gm-Gg: ASbGncuSHpUMjMzYzkf1snNZWvU+g6OMymWjWxDfnvJYZVVVp5WIUd8cgTbninhR3Wi URy5y9rIXHy6mMFkQHceL0rhgT8J2+p3Khf8erxLcdERrLL5GAzMlKpFNk+DEetmlEXkqa832vg == X-Google-Smtp-Source: AGHT+IFbdwItbBA4Se13aCUQr/OfQT1TFGKNL+WaskC6aWkdq9KcdUNUJtV0+CvxNw8nqptmbyjXMf9KvTdYyysVHIM= X-Received: by 2002:a05:6602:154e:b0:84f:44de:9ca3 with SMTP id ca18e2360f4ac-85427e06abamr2111586939f.5.1738642139711; Mon, 03 Feb 2025 20:08:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Marcelo Fernandes Date: Tue, 4 Feb 2025 17:08:48 +1300 X-Gm-Features: AWEUYZmClIKL97e39MwSZbWUsyQ98q17EYEy6cx3H_8JxJRhxesnkM9kNE4GI0o Message-ID: Subject: Re: Logging queries executed by SPI_execute To: Pavel Stehule Cc: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 qu= eries are marked as nested. > > So you need to use auto_explain https://www.postgresql.org/docs/current/a= uto-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 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 woul= d be more handy. Best, Marcelo