Skip to content

Optimize should be skippable - add new lifecycle method #2653

@benjie

Description

@benjie

Optimize is generally used for optimizing steps (e.g. eliminating them by having ancestors do their work for them, or similar); however it's sometimes also used for sending information up the tree where there is no other appropriate time to do it (i.e. data that can't be sent until the full tree is established - like "do I need to load cursors or not" isn't known until we see whether anyone accessed the cursor fields or not).

Here's an example:

// Tell our parent we only need certain attributes
$source.addAttributes(this.attributes);
for (const [key, value] of Object.entries(this.params)) {
$source.setParam(key, value);
}

Saying about the attributes is an optimization (without it, all attributes would be loaded); but saying about the params is required - without it we might not be applying the right filters/etc.

We should add a new lifecycle method that does these essential tree-walking steps before optimize is called. Maybe at the end of plan before or just slightly after tree shaking? (Note: refs should be retained for this.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    🌳 Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions