Re: Bypassing cursors in postgres_fdw to enable parallel plans
Andy Fan <zhihuifan1213@163.com>
From: Andy Fan <zhihuifan1213@163.com>
To: Rafia Sabih <rafia.pghackers@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Robert Haas
<robertmhaas@gmail.com>
Date: 2025-03-12T11:57:34Z
Lists: pgsql-hackers
Rafia Sabih <rafia.pghackers@gmail.com> writes:
Hi,
>
> At present, in postgres_fdw, if a query which is using a parallel plan is fired from the remote end fails to use the
> parallel plan locally because of the presence of CURSORS. Consider the following example,
...
>
> Now, to overcome this limitation, I have worked on this idea (suggested by my colleague Bernd Helmle) of bypassing the
> cursors.
Do you know why we can't use parallel plan when cursor is used? Is It
related to this code in ExecutePlan?
/*
* Set up parallel mode if appropriate.
*
* Parallel mode only supports complete execution of a plan. If we've
* already partially executed it, or if the caller asks us to exit early,
* we must force the plan to run without parallelism.
*/
if (queryDesc->already_executed || numberTuples != 0)
use_parallel_mode = false;
Actually I can't understand the comment as well and I had this
confusion for a long time.
--
Best Regards
Andy Fan