On Fri, Feb 6, 2015 at 2:13 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> The complicated part here seems to me to figure out what we need to
> pass from the parallel leader to the parallel worker to create enough
> state for quals and projection. If we want to be able to call
> ExecScan() without modification, which seems like a good goal, we're
> going to need a ScanState node, which is going to need to contain
> valid pointers to (at least) a ProjectionInfo, an ExprContext, and a
> List of quals. That in turn is going to require an ExecutorState.
> Serializing those things directly doesn't seem very practical; what we
> instead want to do is figure out what we can pass that will allow easy
> reconstruction of those data structures. Right now, you're passing
> the target list, the qual list, the range table, and the params, but
> the range table doesn't seem to be getting used anywhere. I wonder if
> we need it. If we could get away with just passing the target list
> and qual list, and params, we'd be doing pretty well, I think. But
> I'm not sure exactly what that looks like.
IndexBuildHeapRangeScan shows how to do qual evaluation with
relatively little setup:
estate = CreateExecutorState(); econtext = GetPerTupleExprContext(estate); slot =
MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));
/* Arrange for econtext's scan tuple to be the tuple under test */ econtext->ecxt_scantuple = slot;
/* Set up execution state for predicate, if any. */ predicate = (List *) ExecPrepareExpr((Expr *)
indexInfo->ii_Predicate, estate);
Then, for each tuple:
ExecStoreTuple(heapTuple, slot, InvalidBuffer, false);
And:
if (!ExecQual(predicate, econtext, false)) continue;
This looks like a good model to follow for parallel sequential scan.
The point though is that I think we should do it directly rather than
letting the portal machinery do it for us. Not sure how to get
projection working yet.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company