Skip to main content

Module engine

Module engine 

Source
Expand description

Optimizer Engine Module

This module provides a query optimization engine, which is responsible for coordinating and managing all components related to query optimization.

§Design Specifications

OptimizerEngine is the core component of the query optimization layer and is shared and used wherever it is needed through dependency injection. It integrates functions such as statistical information management, cost calculation, and selective estimation, providing a unified optimization service for the query pipeline.

§Explanation of Shared Instances

The OptimizerEngine is designed to be a component that can be shared across multiple queries for the following reasons:

  1. Sharing of statistical information: All queries share the same set of statistical information, ensuring consistency in cost estimates.
  2. Resource Efficiency: Avoid the repeated creation of optimizer components in each query pipeline.
  3. Configuration Consistency: A unified cost model configuration is applied to all queries.

§How to use it

use std::sync::Arc;
use linkrs_query::optimizer::cost::CostModelConfig;
use linkrs_query::optimizer::engine::OptimizerEngine;

// Created during the initialization of the database instance
let optimizer_engine = Arc::new(OptimizerEngine::new(CostModelConfig::default()));

§Thread Safety

OptimizerEngine utilizes Arc as well as thread-safe data structures, which allow for safe sharing in a multi-threaded environment.

§Attention

This is not a global singleton, but an instance that is shared between components through Arc. Each database instance can have its own optimizer engine configuration.

Structs§

OptimizerEngine