Re: Bypassing cursors in postgres_fdw to enable parallel plans
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Andy Fan <zhihuifan1213@163.com>
Cc: Rafia Sabih <rafia.pghackers@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-10-10T19:35:16Z
Lists: 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