MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / optimize

Method optimize

src/adapter/src/optimize/materialized_view.rs:167–196  ·  view source on GitHub ↗
(&mut self, expr: HirRelationExpr)

Source from the content-addressed store, hash-verified

165 type To = LocalMirPlan;
166
167 fn optimize(&mut self, expr: HirRelationExpr) -> Result<Self::To, OptimizerError> {
168 let time = Instant::now();
169
170 // Trace the pipeline input under `optimize/raw`.
171 trace_plan!(at: "raw", &expr);
172
173 // HIR ⇒ MIR lowering and decorrelation
174 let mir_expr = expr.clone().lower(&self.config, Some(&self.metrics))?;
175
176 // MIR ⇒ MIR optimization (local)
177 let mut df_meta = DataflowMetainfo::default();
178 let mut transform_ctx = TransformCtx::local(
179 &self.config.features,
180 &self.typecheck_ctx,
181 &mut df_meta,
182 Some(&mut self.metrics),
183 Some(self.view_id),
184 );
185 let mir_expr = optimize_mir_local(mir_expr, &mut transform_ctx)?.into_inner();
186 let typ = infer_sql_type_for_catalog(&expr, &mir_expr);
187
188 self.duration += time.elapsed();
189
190 // Return the (sealed) plan at the end of this optimization step.
191 Ok(LocalMirPlan {
192 expr: mir_expr,
193 df_meta,
194 typ,
195 })
196 }
197}
198
199impl LocalMirPlan {

Callers

nothing calls this directly

Calls 15

nowFunction · 0.85
optimize_mir_localFunction · 0.85
optimize_dataflowFunction · 0.85
normalize_letsFunction · 0.85
trace_planFunction · 0.85
prep_relation_exprMethod · 0.80
prep_scalar_exprMethod · 0.80

Tested by

no test coverage detected