CTRL + S our souls
Optimization #6

No Root Intermediate Results

Eliminating the overhead of converting internal data structures by producing the final output format directly from the top-level join.

The Bottleneck

In previous iterations, our execution engine used internal structures (like column_t and value_t) optimized for processing speed.

However, the execute() function is required to return a specific ColumnarTable format. This meant that after the final join (the root of the query plan), we were performing an expensive conversion step, copying data from our optimized internal format to the required output format.

The Solution

Root Join
No Copy
Final Output

Writing directly to destination memory.

Direct Output Generation

To complete this optimization, the top-level join must be refactored to produce the ColumnarTable format directly.

This requires distinct logic for the root node compared to internal nodes. Instead of outputting column_t pages, the root join writes results into the final ColumnarTable buffers mandated by the contest interface.

Implementation Strategy

  • Verify value_t

    Ensure the lightweight value types from the previous optimization are stable before attempting this major structural change.

  • Specialized Root Operator

    Create a specialized version of the join operator (or a flag-based branch) that handles memory allocation for the final result format.

The Outcome

Once the root join produces a ColumnarTable directly:

No std::variant Required

We eliminate the need for any variant data types in the output path, resulting in purely static, type-safe, and highly optimized code execution.