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 1viapH-00AcBs-30 for pgsql-general@arkaria.postgresql.org; Wed, 21 Jan 2026 16:13:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1viapH-0086Bd-0H for pgsql-general@arkaria.postgresql.org; Wed, 21 Jan 2026 16:12:59 +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 1viapG-0086BT-1y for pgsql-general@lists.postgresql.org; Wed, 21 Jan 2026 16:12:59 +0000 Received: from mail-dl1-x122c.google.com ([2607:f8b0:4864:20::122c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1viapE-001cOp-1D for pgsql-general@lists.postgresql.org; Wed, 21 Jan 2026 16:12:58 +0000 Received: by mail-dl1-x122c.google.com with SMTP id a92af1059eb24-121bf277922so60350c88.0 for ; Wed, 21 Jan 2026 08:12:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769011976; cv=none; d=google.com; s=arc-20240605; b=Z618Buy0W9gSoaZSNDXDiOvqSHXvI+wXQ1qjTeIG0w7nllkLBzpib0M9SKqs7zovUo t5+RiMhFkRRfU4NIDQTrkXAzRZhACCSsnKC6FCWV8bem+Wmtwn6/5DVeKnXHh8/Qh6+O Vobl1NT0Z3WQx6fatXh6V3a69GDS86kdyxHTJMqJ1Dmd1h17jFbzOn2rSzka+U9Z9kwd W2sf3GNqHjEyMEpLALoHLbg5W7fy8huCXy+6jxgqgKcwFfQ15uQ5WCvOcFomFl8Usl94 4G9fmV6tiJY60sAkH9uil0hGgNcos3C4aFAjxjYuS/QDwqHKIyHh02AKIT8uu7iXJmrL znZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=HPgz7HVqfWyLY17KYn035bc9HABA5J0N2rb/UaaX2qc=; fh=C17ujP850SFtm7oEee4027CB5vYY34lPUL8Hk6FSdZQ=; b=Va877LhMgml+7darYRcXCw8X18/cWbukIVLpvQcz/seA0XJr5ZmlO3vWvJqq8pnQRl YLFW0PszWEBarCPxQvd2P6RY4FACFjxj3YLQyy63HWWVhtAON2U1JMA5KXo9dpKClkiw WnlimBQ8yLphhHRfGMt6VFgjfPAd/2Zzct5njjYrp+7vtbijyPTzZhA/Hn6KKbl7JuLu DFVWz+ngDitZntHRUODtygq9BS3RSG5MLxLSxeJIeAooldsNBZGZrvjRqYDQ4Dprcgvf PBp4WXImhbcZg6mpVmaTCAnXFKoHVesM3eszx/aowRldUnhS5vb0wbP7Vtk6ud1NHDkM 96Ag==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769011976; x=1769616776; 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=HPgz7HVqfWyLY17KYn035bc9HABA5J0N2rb/UaaX2qc=; b=AFic/SubRSIS+j9uNIKUISbVxatqcJwyLpEIxTyekUdOuRTRWZagzdNDwrOyPC1vqg QLPulFdWQvFDmHIkLOKHkwqd+icB6TNFZcxlzFYY8l5iGwMQecNY9I5mGltJ9sQD13/i jvec9RT6ggqFoZiCh8v5fH3mdIYK9TgQmmEPBUGLHOC4oSNudw6yXd1p8SOHGTK5hLHG A35+IooI8+eG/Mdet67d5NJb5ZRGws2GPZjcrHYtBMa7Ro1wma5A6eeWQvhtiUMNIQjJ +ry/lGHbzHCu1VSHifgLNQBJKmgXj/w9UVZ4R13OWCGMvfOItEZH/vW37RFZF+elMctp FtkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769011976; x=1769616776; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HPgz7HVqfWyLY17KYn035bc9HABA5J0N2rb/UaaX2qc=; b=vhZEcNmx7itrdK0FsminH+EsNChCMshJ5atFtsD+t2q/E/l6DplvZY56bi0yrciYc0 dvDsQHWHI53g439B3dUfH4AZh/ENs8SgJz9Yko0pG1o4yTeEVyR8J6K+Hp4ufbcs5Rp3 xjsVPYKU1Zu91AgDhhq7e47JBM4MKRhDRStLD9MEkPI4pizjmt+ugfcfMnXK/h2de3n2 xbYj84PpyKDXYnj09GoeDYBxN1VqpQeeCr9PDc+08H0tc9bUj5aH50f1WJlSgfbyXCzk Ya+HwL0KuV4mUqPAk4a19aA1bMb0u82wbcedHm25b965vcz1dGBpj6VXWa5y6StXDmgw m7RQ== X-Gm-Message-State: AOJu0Yw8NMciFUJVXSOH+a0Wk2PxBlKQTUgg638JRPKd/xY7dgH9zFem s7fOpvNDNYbpfZZrgqFMjrAqXu4BAD5RPF8RAt1Y68N5RZT+G/dZw6OqeWct7d2aJe9AnrwPdZB z0Rt9+0RRPd2kSkamLQUZv4rILCnP6hyMZnzr X-Gm-Gg: AZuq6aL3opU2pl5304HQhUvVl6PO6jG6nn25AiCMhoTyCelUBjdWiRrblQ6Y+YEJ4An r5nTaGYTUkUdRwkmv0M3x7bbslcmIrc/NwQz+qQ7xSkWLEg4gVQ0amWLMdO3odzj5rlqsriTP9C bOKW+QiO4scLJhMERF0o02e7Meom8pdKR0WsSwnmI6oMm0tlWHFjrEsCYeUaLglLp3mj8Mth1m1 h48Ef77/ZCtzxDS4xwDe0zuMEsnFdqWbojStGkuDoCSneJhiw1VLV6KUblxIltljt0bxLy6JtZw CXx7ZR7yNxmi5eaSXtxsBgrryxnolVBCREJkd6yqgJFoE5guKUDHvs6lHMchHJM202RHgQQNYvn aAJF9SoFzMTjmG4yRv/nE8OGgkvVSyx3n4TY/OMgBKDiKEc7OwBZf+oZl7+3IFoeqdtrb X-Received: by 2002:a05:7022:48e:b0:119:e569:f60d with SMTP id a92af1059eb24-1244b304b60mr14863818c88.6.1769011976046; Wed, 21 Jan 2026 08:12:56 -0800 (PST) MIME-Version: 1.0 References: <31af308b-1689-44e8-ab88-f6a72722b38b@aklaver.com> In-Reply-To: <31af308b-1689-44e8-ab88-f6a72722b38b@aklaver.com> From: "Colin 't Hart" Date: Wed, 21 Jan 2026 17:12:44 +0100 X-Gm-Features: AZwV_QgsEFLOLpdeFZmCEmvMujdQD7yYww_chtxVfWmMkxR6IEQkjCy07NLPgEg Message-ID: Subject: Re: pgBadger and postgres_fdw To: Adrian Klaver Cc: PostgreSQL General Content-Type: multipart/alternative; boundary="0000000000006f8c560648e8322f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006f8c560648e8322f Content-Type: text/plain; charset="UTF-8" 1. Migration from one server to another. Newer OS (Debian 12 vs Ubuntu 20.04), same version of Postgres (17). 2. postgres_fdw is to different databases within the same cluster. 3. 17 4. No new analyze was done; migration was achieved by moving the disks between the virtual servers. We reindexed all text indexes to allow for the new glibc version on Debian 12. 5. That's the thing: I have no idea which queries the `fetch 100 from c2` are associated with because the `c2` seems to be reused for each query. The psycopg python library generates unique server-side cursor names, but postgres_fdw doesn't. 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. Thanks, Colin On Wed, 21 Jan 2026 at 16:43, Adrian Klaver wrote: > On 1/21/26 00:18, Colin 't Hart wrote: > > Hi, > > > > One of my clients makes extensive use of postgres_fdw. After a migration > > performance isn't great. pgBadger reports show the slowest queries all > > being `fetch 100 from c2`. > > > > Anyone have any tricks for being able to associate those fetches with > > the queries that were used when declaring the server-side cursor? > > This is going to need a lot more information. To start: > > 1) Migration of what and from what version to what version? > > 2) Where are the Postgres databases relative to each other on the network? > > 3) What versions of Postgres if not covered in 1. > > 4) If Postgres was what was being updated was an analyze done on the > instances? > > 5) Show a complete query using EXPLAIN ANALYZE. > > 6) Define slow. > > > > > Thanks, > > > > Colin > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > --0000000000006f8c560648e8322f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
1. Migration from one server to another. Newer OS (De= bian 12 vs Ubuntu 20.04), same version of Postgres (17).
2. postg= res_fdw is to different databases within the same cluster.
3. 17<= /div>
4. No new analyze was done; migration was achieved by moving the = disks between the virtual servers. We reindexed all text indexes to allow f= or the new glibc version on Debian 12.
5. That's the thing: I= have no idea which queries the `fetch 100 from c2` are associated with bec= ause the `c2` seems to be reused for each query. The psycopg python library= generates unique server-side cursor names, but postgres_fdw doesn't.
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 c= 2`.

The slowness itself isn't my question here= ; it was caused by having too few cores in the new environment, while the a= pplication was still assuming the higher core count and generating too many= concurrent processes.

My question is how to ident= ify 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.

Thanks,<= /div>

Colin

On Wed, 21 Jan 20= 26 at 16:43, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 1/21/26 00:18, Colin 't Hart wrote:
> Hi,
>
> One of my clients makes extensive use of postgres_fdw. After a migrati= on
> performance isn't great. pgBadger reports show the slowest queries= all
> being `fetch 100 from c2`.
>
> Anyone have any tricks for being able to associate=C2=A0those fetches = with
> the queries that were used when declaring the server-side cursor?

This is going to need a lot more information. To start:

1) Migration of what and from what version to what version?

2) Where are the Postgres databases relative to each other on the network?<= br>
3) What versions of Postgres if not covered in 1.

4) If Postgres was what was being updated was an analyze done on the
instances?

5) Show a complete query using EXPLAIN ANALYZE.

6) Define slow.

>
> Thanks,
>
> Colin


--
Adrian Klaver
adrian.klave= r@aklaver.com
--0000000000006f8c560648e8322f--