Re: pgBadger and postgres_fdw

Laurenz Albe <laurenz.albe@cybertec.at>

From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Colin 't Hart <colinthart@gmail.com>, Adrian Klaver <adrian.klaver@aklaver.com>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Date: 2026-01-21T18:57:26Z
Lists: pgsql-general
On Wed, 2026-01-21 at 17:12 +0100, Colin 't Hart wrote:
> 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.

I would inverstigate that on the remote database.

If the user that postgres_fdw uses to connect is remote_user, you could

  ALTER ROLE remote_user SET log_min_duretion_statement = 0;

Then any statements executed through postgres_fdw would be logged.

If you have %x in log_line_prefix, you can find the DECLARE statement that declared
the cursor that takes so long to fetch.  Not very comfortale, but it should work.

Yours,
Laurenz Albe