Expand description
Optimizer interface to the adapter and coordinator code.
The goal of this crate is to abstract optimizer specifics behind a high-level interface that is ready to be consumed by the coordinator code in a future-proof way (that is, the API is taking the upcoming evolution of these components into account).
The contents of this crate should have minimal dependencies to the rest of the coordinator code so we can pull them out as a separate crate in the future without too much effort.
The main type in this module is a very simple Optimize trait which
allows us to adhere to the following principles:
- Implementors of this trait are structs that encapsulate all context
required to optimize a statement of type
Tend-to-end (for examplematerialized_view::OptimizerforT=MaterializedView). - Each struct implements
Optimizeonce for each optimization stage. TheFromtype represents the input of the stage andSelf::Tothe associated stage output. This allows to have more than one entrypoints to a pipeline. - The concrete types used for stage results are opaque structs that are
specific to the pipeline of that statement type.
- We use different structs even if two statement types might have structurally identical intermediate results. This ensures that client code cannot first execute some optimization stages for one type and then some stages for a different type.
- The only way to construct such a struct is by running the
Optimizestage that produces it. This ensures that client code cannot interfere with the pipeline. - In general, the internals of these structs can be accessed only behind a shared reference. This ensures that client code can look up information from intermediate stages but cannot modify it.
- Timestamp selection is modeled as a conversion between structs that are
adjacent in the pipeline using a method called
resolve. - The struct representing the result of the final stage of the
optimization pipeline can be destructed to access its internals with a
method called
unapply.
- The
Sendtrait bounds on theSelfandFromtypes ensure thatOptimizeinstances can be passed to different threads (this is required of off-thread optimization).
For details, see the 20230714_optimizer_interface.md design doc in this
repository.
Modulesยง
- copy_to
- Optimizer implementation for
COPY TOstatements. - dataflows
- Types and methods for building and shipping dataflow descriptions.
- index
- Optimizer implementation for
CREATE INDEXstatements. - materialized_
view - Optimizer implementation for
CREATE MATERIALIZED VIEWstatements. - peek
- Optimizer implementation for
SELECTstatements. - subscribe
- Optimizer implementation for
SUBSCRIBEstatements. - view
- An Optimizer that
Macrosยง
- trace_
plan ๐
Structsยง
- Optimizer
Config - Feature flags for the optimizer.
Enumsยง
- Optimize
Mode - Optimizer
Error - Error types that can be generated during optimization.
Traitsยง
- Optimize
- A trait that represents an optimization stage.
- Optimizer
Catalog
Functionsยง
- optimize_
mir_ ๐constant - This is just a wrapper around mz_transform::Optimizer::constant_optimizer, running it, and tracing the result plan.
- optimize_
mir_ ๐local
Type Aliasesยง
- LirDataflow
Description ๐ - A type for a
DataflowDescriptionbacked byLir~plans. Used internally by the optimizer implementations. - MirDataflow
Description ๐ - A type for a
DataflowDescriptionbacked byMir~plans. Used internally by the optimizer implementations.