On Sun, Aug 2, 2015 at 8:06 AM, Kouhei Kaigai <kai...@ak.jp.nec.com> wrote: > > Amit, > > Let me ask three more detailed questions. > > Why Funnel has a valid qual of the subplan? > The 2nd argument of make_funnel() is qualifier of the subplan > (PartialSeqScan) then it is initialized at ExecInitFunnel, > but never executed on the run-time. Why does Funnel node has > useless qualifier expression here (even though it is harmless)? >
The idea is that if in some case the qualification can't be pushed down (consider the case where qualification contains parallel restricted functions (functions that can only be executed in master backend)) and needs to be only executed in master backend, then we need it in Funnel node, so that it can be executed for tuples passed by worker backends. It is currently not used, but I think we should retain it as it is because it can be used in some cases either as part of this patch itself or in future. As of now, it is used in other places in patch (like during Explain) as well, although we might want to optimize the same, but overall I think it is required. > Why Funnel delivered from Scan? Even though it constructs > a compatible target-list with underlying partial-scan node, > it does not require the node is also delivered from Scan. It needs it's own target-list due to reason mentioned above for qual and yet another reason is that the same is required for FunnelState which inturn is required ScanSlot used to retrieve tuples from workers. Also it is not excatly same as partialseqscan, because for the case when the partialseqscan node is executed by worker, we modify the targetlist as well, refer create_parallel_worker_plannedstmt(). > > Does ExecFunnel() need to have a special code path to handle > EvalPlanQual()? Probably, it just calls underlying node in the > local context. ExecScan() of PartialSeqScan will check its > qualifier towards estate->es_epqTuple[]. > Isn't EvalPlanQual() called for modifytable node and which won't be allowed in parallel mode, so I think EvalPlanQual() is not required for ExecFunnel path. With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com