pub struct CostBasedOptimizer { /* private fields */ }Expand description
Cost-based query optimizer
Implementations§
Source§impl CostBasedOptimizer
impl CostBasedOptimizer
pub fn new(config: CostModelConfig) -> Self
Sourcepub fn with_plan_cache_ttl_ms(self, ttl_ms: u64) -> Self
pub fn with_plan_cache_ttl_ms(self, ttl_ms: u64) -> Self
Set plan cache TTL
Sourcepub fn with_token_budget(self, budget: u64, tokens_per_row: f64) -> Self
pub fn with_token_budget(self, budget: u64, tokens_per_row: f64) -> Self
Set token budget for result limiting
Sourcepub fn update_stats(&self, stats: TableStats)
pub fn update_stats(&self, stats: TableStats)
Update table statistics
Sourcepub fn get_stats(&self, table: &str) -> Option<TableStats>
pub fn get_stats(&self, table: &str) -> Option<TableStats>
Get table statistics
Sourcepub fn optimize(
&self,
table: &str,
columns: Vec<String>,
predicate: Option<Predicate>,
order_by: Vec<(String, SortDirection)>,
limit: Option<u64>,
) -> PhysicalPlan
pub fn optimize( &self, table: &str, columns: Vec<String>, predicate: Option<Predicate>, order_by: Vec<(String, SortDirection)>, limit: Option<u64>, ) -> PhysicalPlan
Optimize a SELECT query
Sourcepub fn get_plan_cost(&self, plan: &PhysicalPlan) -> f64
pub fn get_plan_cost(&self, plan: &PhysicalPlan) -> f64
Get estimated cost from a plan
Sourcepub fn explain(&self, plan: &PhysicalPlan) -> String
pub fn explain(&self, plan: &PhysicalPlan) -> String
Generate EXPLAIN output
Source§impl CostBasedOptimizer
impl CostBasedOptimizer
Sourcepub fn evict_stale_plans(&self)
pub fn evict_stale_plans(&self)
Evict stale entries from the plan cache.
Sourcepub fn invalidate_plan_cache(&self)
pub fn invalidate_plan_cache(&self)
Clear the entire plan cache (call after DDL or bulk load).
Sourcepub fn collect_stats(
&self,
table_name: &str,
row_count: u64,
size_bytes: u64,
column_values: HashMap<String, Vec<String>>,
indices: Vec<IndexStats>,
)
pub fn collect_stats( &self, table_name: &str, row_count: u64, size_bytes: u64, column_values: HashMap<String, Vec<String>>, indices: Vec<IndexStats>, )
Collect fresh statistics for a table from row data.
Pass an iterator of (column_name, value_as_string) pairs per row. This builds column stats with distinct counts and optional histograms.
Sourcepub fn stats_age_us(&self, table: &str) -> Option<u64>
pub fn stats_age_us(&self, table: &str) -> Option<u64>
Check if stats are stale (older than threshold)
Auto Trait Implementations§
impl Freeze for CostBasedOptimizer
impl !RefUnwindSafe for CostBasedOptimizer
impl Send for CostBasedOptimizer
impl Sync for CostBasedOptimizer
impl Unpin for CostBasedOptimizer
impl !UnwindSafe for CostBasedOptimizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more