Re: initial pruning in parallel append
От | Amit Langote |
---|---|
Тема | Re: initial pruning in parallel append |
Дата | |
Msg-id | CA+HiwqFtS2hRsfL4xjFLsBo2GE3T0UAQKGAiZoZ6syukMc0dmg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: initial pruning in parallel append (Robert Haas <robertmhaas@gmail.com>) |
Ответы |
Re: initial pruning in parallel append
(Robert Haas <robertmhaas@gmail.com>)
|
Список | pgsql-hackers |
On Wed, Aug 9, 2023 at 9:48 PM Robert Haas <robertmhaas@gmail.com> wrote: > On Wed, Aug 9, 2023 at 6:22 AM Amit Langote <amitlangote09@gmail.com> wrote: > > > > I'm assuming it's not > > > > too ugly if ExecInitAppend() uses IsParallelWorker() to decide whether > > > > it should be writing to EState.es_part_prune_results or reading from > > > > it -- the former if in the leader and the latter in a worker. > > > > > > I don't think that's too ugly. I mean you have to have an if statement > > > someplace. > > > > Yes, that makes sense. > > > > It's just that I thought maybe I haven't thought hard enough about > > options before adding a new IsParallelWorker(), because I don't find > > too many instances of IsParallelWorker() in the generic executor code. > > I think that's because most parallel worker-specific logic lives in > > execParallel.c or in Exec*Worker() functions outside that file, so the > > generic code remains parallel query agnostic as much as possible. > > Oh, actually, there is an issue here. IsParallelWorker() is not the > right test. Imagine that there's a parallel query which launches some > workers, and one of those calls a user-defined function which again > uses parallelism, launching more workers. This may not be possible > today, I don't really remember, but the test should be "am I a > parallel worker with respect to this plan?" not "am I a parallel > worker at all?".Not quite sure what the best way to code that is. If > we could just test whether we have a ParallelWorkerContext, it would > be easy... I checked enough to be sure that IsParallelWorker() is reliable at the time of ExecutorStart() / ExecInitNode() in ParallelQueryMain() in a worker. However, ParallelWorkerContext is not available at that point. Here's the relevant part of ParallelQueryMain(): /* Start up the executor */ queryDesc->plannedstmt->jitFlags = fpes->jit_flags; ExecutorStart(queryDesc, fpes->eflags); /* Special executor initialization steps for parallel workers */ queryDesc->planstate->state->es_query_dsa = area; if (DsaPointerIsValid(fpes->param_exec)) { char *paramexec_space; paramexec_space = dsa_get_address(area, fpes->param_exec); RestoreParamExecParams(paramexec_space, queryDesc->estate); } pwcxt.toc = toc; pwcxt.seg = seg; ExecParallelInitializeWorker(queryDesc->planstate, &pwcxt); BTW, we do also use IsParallelWorker() in ExecGetRangeTableRelation() which also probably only runs during ExecInitNode(), same as ExecInitPartitionPruning() that this patch adds it to. -- Thanks, Amit Langote EDB: http://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: