pub struct QueryPlanner { /* private fields */ }Expand description
Stateful planner wrapper that memoizes query plans by SQL template and schema cookie.
The caller is responsible for supplying a stable SQL template string for the query shape being planned. Literal normalization, placeholder canonicalization, and any higher-level SQL parsing remain above this crate’s current scope.
Implementations§
Source§impl QueryPlanner
impl QueryPlanner
Sourcepub fn with_plan_cache_capacity(capacity: usize) -> Self
pub fn with_plan_cache_capacity(capacity: usize) -> Self
Construct a planner with a caller-provided cache capacity.
A zero capacity is clamped to 1 so callers can tune the cache without
dealing with NonZeroUsize.
Sourcepub fn plan_cache_len(&self) -> usize
pub fn plan_cache_len(&self) -> usize
Return the number of cached plans currently retained.
Sourcepub fn is_plan_cache_empty(&self) -> bool
pub fn is_plan_cache_empty(&self) -> bool
Return true when no cached plans are currently retained.
Sourcepub fn clear_plan_cache(&mut self)
pub fn clear_plan_cache(&mut self)
Clear all cached plans and forget the schema cookie they were built under.
Sourcepub fn cached_plan<F>(
&mut self,
sql_template: &str,
schema_cookie: u32,
build: F,
) -> Rc<QueryPlan>
pub fn cached_plan<F>( &mut self, sql_template: &str, schema_cookie: u32, build: F, ) -> Rc<QueryPlan>
Return a cached plan for the given SQL template and schema cookie, or compute one.
When the schema cookie changes, the entire cache is flushed because any DDL may invalidate earlier planning decisions.
Sourcepub fn order_joins_with_cache(
&mut self,
sql_template: &str,
schema_cookie: u32,
tables: &[TableStats],
indexes: &[IndexInfo],
where_terms: &[WhereTerm<'_>],
needed_columns: Option<&[String]>,
cross_join_pairs: &[(String, String)],
table_index_hints: Option<&BTreeMap<String, IndexHint>>,
cracking_hints: Option<&mut CrackingHintStore>,
feature_flags: PlannerFeatureFlags,
) -> Rc<QueryPlan>
pub fn order_joins_with_cache( &mut self, sql_template: &str, schema_cookie: u32, tables: &[TableStats], indexes: &[IndexInfo], where_terms: &[WhereTerm<'_>], needed_columns: Option<&[String]>, cross_join_pairs: &[(String, String)], table_index_hints: Option<&BTreeMap<String, IndexHint>>, cracking_hints: Option<&mut CrackingHintStore>, feature_flags: PlannerFeatureFlags, ) -> Rc<QueryPlan>
Cached wrapper around order_joins_with_hints_and_features.
This preserves the current stateless free-function API while exposing a planner-local cache for repeated SELECT templates.