エクゼキュータ

The executor takes the plan handed back by the planner/optimizer and starts processing the top node. In the case of our example (the query given in example \ref{simple_select}) the top node is a MergeJoin node.

エクゼキュータはプランナ/オプティマイザによって 戻されたプランを取得し、最上ノードの処理を開始します。ここにあげた例 (例 \ref{simple_select} で与えられた問合せ)の場合、最上ノードは MergeJoin ノードです。

Before any merge can be done two tuples have to be fetched (one from each subplan). So the executor recursively calls itself to process the subplans (it starts with the subplan attached to lefttree). The new top node (the top node of the left subplan) is a SeqScan node and again a tuple has to be fetched before the node itself can be processed. The executor calls itself recursively another time for the subplan attached to lefttree of the SeqScan node.

マージ処理をする前に(それぞれのサブプランから)対のタプルがフェッチされなければ なりません。従い、エグゼキュータはそれ自身を再帰的に(lefttree に付 いているサブプランから始めて)サブプランの処理のため呼び出します。 新しい最上ノード(左の サブプランの最上ノード)は SeqScan ノードで、ノード自身が処理 される前、同様にタプルがフェッチされていなければなりません。 SeqScan ノードの lefttree に付くサブプランに 対してエグゼキュータは再帰的に別途自分自身を呼び出します。

Now the new top node is a Sort node. As a sort has to be done on the whole relation, the executor starts fetching tuples from the Sort node's subplan and sorts them into a temporary relation (in memory or a file) when the Sort node is visited for the first time. (Further examinations of the Sort node will always return just one tuple from the sorted temporary relation.)

ここに至って、新規の最上ノードは Sort です。ソートは全体の リレーションに亘って行われなければならないため、エグゼキュータは Sort ノードの サブプランからタプルのフェッチを開始して、Sort ノードが始めて巡回 された時には(メモリまたはファイルとして)暫定リレーションにソート結果を出力します。 (以降の Sort ノードの検証ではソートされた暫定リレーション から、たった一つのタプルが常に戻されます。)

Every time the processing of the Sort node needs a new tuple the executor is recursively called for the SeqScan node attached as subplan. The relation (internally referenced by the value given in the scanrelid field) is scanned for the next tuple. If the tuple satisfies the qualification given by the tree attached to qpqual it is handed back, otherwise the next tuple is fetched until the qualification is satisfied. If the last tuple of the relation has been processed a NULL pointer is returned.

Sort ノードの処理にはいつでも、エクゼキュータが再帰的に呼び出される サブプランとして付けられた SeqScan ノードに対する新規タプルが必要です。 リレーション(内部的には scanrelid フィールドによって参照されます) は次のタプルに対しスキャンされます。qpqual に付いたツリーによって 与えられた条件をタプルが満たしていれば、そのタプルは返され、そうでなければ条件 が満足されるまで次のタプルがフェッチされます。リレーションの最後のタプルが処理 されると NULL ポインタが返されます。

After a tuple has been handed back by the lefttree of the MergeJoin the righttree is processed in the same way. If both tuples are present the executor processes the MergeJoin node. Whenever a new tuple from one of the subplans is needed a recursive call to the executor is performed to obtain it. If a joined tuple could be created it is handed back and one complete processing of the plan tree has finished.

MergeJoinlefttree によってタプルが 返された後、同様にして righttree が処理されます。 もし二つのタプルが実存すれば、エグゼキュータは MergeJoin ノード の処理を行います。サブプランのどれかからの新規タプルが必要とされた場合、 それを取得するためエクゼキュータに対して再帰的に呼び出しが行われます。 join したタプルが生成された場合、そのタプルは戻されて、一つのプランツリーの処理が 完結します。

Now the described steps are performed once for every tuple, until a NULL pointer is returned for the processing of the MergeJoin node, indicating that we are finished.

MergeJoin ノードの処理に対して、処理の完了を意味する NULL ポインタが返されるまで上に記述したステップがそれ ぞれのタプルに対して一度づつ行われます。