pub struct RuntimeFeedbackStore { /* private fields */ }Expand description
Persistent store of historical query execution statistics.
Keeps at most max_history entries per query hash.
Implementations§
Source§impl RuntimeFeedbackStore
impl RuntimeFeedbackStore
Sourcepub fn new(max_history: usize) -> Self
pub fn new(max_history: usize) -> Self
Create a new store that retains up to max_history records per query.
Sourcepub fn record(&mut self, stats: QueryStats)
pub fn record(&mut self, stats: QueryStats)
Record a new execution statistics entry.
If the per-query history is already at capacity the oldest entry is dropped before the new one is appended.
Sourcepub fn get_stats(&self, query_hash: u64) -> &[QueryStats]
pub fn get_stats(&self, query_hash: u64) -> &[QueryStats]
Return the recorded history for a query, or an empty slice when none exists.
Sourcepub fn estimate_selectivity(&self, pattern: &str) -> f64
pub fn estimate_selectivity(&self, pattern: &str) -> f64
Estimate the selectivity of a triple-pattern string from historical data.
Averages the per-pattern selectivity across all historical entries that
contain an observation for pattern. Returns 0.1 as a default when
no data is available.
Sourcepub fn estimate_cardinality(&self, pattern: &str, base_estimate: usize) -> usize
pub fn estimate_cardinality(&self, pattern: &str, base_estimate: usize) -> usize
Estimate cardinality for a pattern given a base estimate.
Adjusts base_estimate using the average observed selectivity.
Falls back to base_estimate when no historical data exists (since
default selectivity 0.1 / 0.1 = ratio 1.0).
Sourcepub fn best_join_order(&self, query_hash: u64) -> Option<Vec<String>>
pub fn best_join_order(&self, query_hash: u64) -> Option<Vec<String>>
Return the join order associated with the lowest average execution time
for a given query hash, or None when no history exists.
Sourcepub fn prune_old(&mut self, max_age_ms: u64)
pub fn prune_old(&mut self, max_age_ms: u64)
Remove all statistics entries where execution_time_ms >= max_age_ms.
Entries with execution time below max_age_ms are retained.
Empty query buckets are also removed.
Sourcepub fn stats_count(&self) -> usize
pub fn stats_count(&self) -> usize
Total number of statistics entries across all queries.
Sourcepub fn query_count(&self) -> usize
pub fn query_count(&self) -> usize
Number of distinct query hashes for which history has been recorded.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RuntimeFeedbackStore
impl RefUnwindSafe for RuntimeFeedbackStore
impl Send for RuntimeFeedbackStore
impl Sync for RuntimeFeedbackStore
impl Unpin for RuntimeFeedbackStore
impl UnsafeUnpin for RuntimeFeedbackStore
impl UnwindSafe for RuntimeFeedbackStore
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
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>
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>
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