Query plan execution

Execution of a query plan involves five phases:

  1. Acquire – acquires resources needed for execution, such as memory buffers and worktables.

  2. Open – prepares to return result rows.

  3. Next – generates the next result row.

  4. Close – cleans up; for example, notifies the access layer that scanning is complete, or truncate worktables.

  5. Release – releases resources obtained during the acquire phase, such as memory buffers and worktables.

Each operator has a method with the same name as the phase, which is invoked for each of these phases.

The query plan in Figure 1-2 demonstrates query plan execution:

After successfully completing the Release phase of execution, the query engine returns control to the procedural execution engine for final statement processing.