Re: Bypassing cursors in postgres_fdw to enable parallel plans - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Bypassing cursors in postgres_fdw to enable parallel plans
Date
Msg-id CA+TgmoaLV6CmkdKFf1JUGm-MVFrmi23w_jQ3fLqLeywgwTCE=A@mail.gmail.com
Whole thread Raw
In response to Re: Bypassing cursors in postgres_fdw to enable parallel plans  (Andy Fan <zhihuifan1213@163.com>)
List pgsql-hackers
On Wed, Mar 12, 2025 at 7:57 AM Andy Fan <zhihuifan1213@163.com> wrote:
> Do you know why we can't use parallel plan when cursor is used? Is It
> related to this code in ExecutePlan?

Yes. When a cursor is used, the whole query isn't executed all at
once, but rather the executor will be started and stopped for each
fetch from the cursor. We can't keep the parallel workers running for
that whole time, not just because it would be inefficient, but because
it would be incorrect. State changes would be possible in the leader
that were not reflected in the workers, leading to chaos.

--
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Andrey Borodin
Date:
Subject: Re: Remove custom redundant full page write description from GIN
Next
From: Nathan Bossart
Date:
Subject: Re: another autovacuum scheduling thread