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.96) (envelope-from ) id 1vibsJ-00B5YX-0O for pgsql-general@arkaria.postgresql.org; Wed, 21 Jan 2026 17:20:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vibsI-008MQH-0H for pgsql-general@arkaria.postgresql.org; Wed, 21 Jan 2026 17:20:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vibsH-008MQ8-2T for pgsql-general@lists.postgresql.org; Wed, 21 Jan 2026 17:20:10 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vibsF-001cxn-0F for pgsql-general@lists.postgresql.org; Wed, 21 Jan 2026 17:20:09 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 602D6EC010A; Wed, 21 Jan 2026 12:20:06 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Wed, 21 Jan 2026 12:20:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1769016006; x=1769102406; bh=fprS37w7D95uoz2cfhAd8ro8Tgk4ykt8dwDGwdiDhFY=; b= DWsnj/aObHjCdCPasiFrqXXpeV7VpKMpSU9aJ147+tT4/0e/PurhvMijduUjM+KG 2uhsxdQTREYHO3jXYmBLC/t+Aqy+AULkgL9coZkpIo/CSTmlTCEEZGx7xsBDksuK 8rIBLtgQOX5nKTem5RpdX8g6dV4bFKFbaugmHHsJC1cYWDacIbGmT570s6X+lTv+ TSecpdcKBt5OffRfZCPO5vrDcxVQG8AaCQ1qB1tcgUdly2VbbGD+ioU4tBC5t0uo f9lYy47ISlyMKYP/7dE7ycfd81hPa27O0xpCkBCqz9flEEe1MsO/SR+K8pmt4w1F MrW83DLzcfrBpCn6wScj7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1769016006; x= 1769102406; bh=fprS37w7D95uoz2cfhAd8ro8Tgk4ykt8dwDGwdiDhFY=; b=e l26vyQurouV4WdXLBauvH199ToI4RRNS6i0W7/2pqlQ9YVa1Vv/Htpd/pKo/b2il CyJADa10rCfQfcDli9O1ud5etz82unNLZ3X9iFzqgmJX2x/DPYDOXgMTwUrAogbg ybFe+VkZKDCQepMLjpwnEASpeKJA8qi1Ou4wNiK9JZo6cnDGKK+RAbo8LtbA14Nd SQNBr3ygFA+9wbBuaMugPOvNpm9h/Yu+merA9OAXFwpCVIx570QDsrjjbDUdygym yK/Y5gl3ic+KukGUFJpqIzHPsUAHqR5GvOivoaS5BzqIA2v552ntpQsfU8vKoWZ3 mBjostB+3ZaHSVW92EnWA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddugeefkeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffhvfevfhgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepvdffhfdvkedvfeegteffkeeuvdduhefggeejveduudeu fffggfevhfeuvdefkefgnecuffhomhgrihhnpehgihhthhhusgdrtghomhdpphhoshhtgh hrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspg hrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheptgholhhinhht hhgrrhhtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlh eslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Jan 2026 12:20:03 -0500 (EST) Message-ID: <19c6bc0a-a560-4889-8902-093328fe41c5@aklaver.com> Date: Wed, 21 Jan 2026 09:20:02 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pgBadger and postgres_fdw From: Adrian Klaver To: Colin 't Hart Cc: PostgreSQL General References: <31af308b-1689-44e8-ab88-f6a72722b38b@aklaver.com> <1013bd5d-5356-497b-ae06-c02dc53caf92@aklaver.com> Content-Language: en-US In-Reply-To: <1013bd5d-5356-497b-ae06-c02dc53caf92@aklaver.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/21/26 08:59, Adrian Klaver wrote: > On 1/21/26 08:12, Colin 't Hart wrote: > >> 6. The 19 slowest queries in a 4 hour period are between 2 and 37 >> minutes, with an average of over 10 minutes; they are all `fetch 100 >> from c2`. >> >> The slowness itself isn't my question here; it was caused by having >> too few cores in the new environment, while the application was still >> assuming the higher core count and generating too many concurrent >> processes. >> >> My question is how to identify which connections / queries from >> postgres_fdw are generating the `fetch 100 from c2` queries, which, in >> turn, may quite possibly lead to a feature request for having these >> named uniquely. > > My guess not. > > See: > > https://github.com/postgres/postgres/blob/master/contrib/postgres_fdw/ > postgres_fdw.c > > Starting at line ~5212 > > fetch_size = 100; > > and ending at line ~5234 > > /* Construct command to fetch rows from remote. */ >     snprintf(fetch_sql, sizeof(fetch_sql), "FETCH %d FROM c%u", >              fetch_size, cursor_number); > > So c2 is a cursor number. If I am following this something postgres_fdw does to fetch the result in batches, so all the queries will have them. FYI, the fetch_size can be changed, see here: https://www.postgresql.org/docs/17/postgres-fdw.html#POSTGRES-FDW-CONFIGURATION-PARAMETERS F.36.1.4. Remote Execution Options If you want connection/query information I would enable from here: https://www.postgresql.org/docs/17/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT log_connections log_disconnections And at least temporarily: log_statement = 'all' The above will generate a lot of logs so you don't want to keep set for too long. > >> >> Thanks, >> >> Colin >> > > > -- Adrian Klaver adrian.klaver@aklaver.com