Re: postgres_fdw prefers fast plans

From: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: postgres_fdw prefers fast plans
Date: 2025-12-11 06:38:13
Message-ID: 38fda8ab075440f876f88970e6f614b4@postgrespro.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Laurenz Albe писал(а) 2025-12-10 16:12:
> On Wed, 2025-12-10 at 15:44 +0300, Alexander Pyhalov wrote:
>> There's a long-standing issue with postgres_fdw - as it uses cursors,
>> it
>> prefers plans, optimized for fetching first rows. In bad scenarios
>> this
>> leads to suboptimal choice of join methods (e.g. choosing nest loop
>> over
>> hash join) on remote side. I've crafted WIP patch, which tries to fix
>> this issue. It adds FETCH ALL cursors and uses them in postgres_fdw.
>> What do you think? Should we go in this direction?
>
> Why not simply set cursor_tuple_fraction to 1.0 in postgres_fdw
> sessions?
>
> Yours,
> Laurenz Albe

Hi.
Haven't thought about this. Thanks for the idea. The only drawback I see
is that this will affect all cursors, which can be used, for example, by
shippable functions. But looks much simpler.
--
Best regards,
Alexander Pyhalov,
Postgres Professional

Attachment Content-Type Size
0001-postgres_fdw-expect-that-all-tuples-are-needed.patch text/x-diff 46.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ioseph Kim 2025-12-11 06:39:16 Re: Propose: Adding a '--enable-failover' option to 'pg_createsubscriber' ver.3
Previous Message Amit Kapila 2025-12-11 06:19:21 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart