pub struct CachedPlan {
pub plan: QueryPlan,
pub cached_at: Instant,
pub access_count: u64,
pub last_accessed: Instant,
pub shape_key: Option<String>,
pub exact_query: Option<Arc<str>>,
pub state: CacheEntryState,
pub expected_rows_scanned: Option<u64>,
pub last_observed_rows_scanned: Option<u64>,
pub parameter_count: usize,
pub replan_pending: bool,
}Expand description
A cached query plan with metadata
Fields§
§plan: QueryPlanThe compiled query plan
cached_at: InstantWhen this plan was cached
access_count: u64Number of times this plan was accessed
last_accessed: InstantLast access time
shape_key: Option<String>Query shape key used for parameter-insensitive cache grouping.
exact_query: Option<Arc<str>>Last exact query string stored in this slot.
state: CacheEntryStateRuntime activation state inspired by Mongo’s active/inactive plan cache.
expected_rows_scanned: Option<u64>Moving expectation for storage reads (rows_scanned) on this shape.
last_observed_rows_scanned: Option<u64>Last observed runtime reads for the shape.
parameter_count: usizeNumber of literal binds expected by the cached shape skeleton.
replan_pending: boolWhen true, the next cache lookup forces a fresh replan.
Implementations§
Source§impl CachedPlan
impl CachedPlan
Sourcepub fn new(plan: QueryPlan) -> CachedPlan
pub fn new(plan: QueryPlan) -> CachedPlan
Create a new cached plan
pub fn with_shape_key(self, shape_key: impl Into<String>) -> CachedPlan
pub fn with_exact_query(self, query: impl Into<String>) -> CachedPlan
pub fn with_parameter_count(self, parameter_count: usize) -> CachedPlan
Sourcepub fn is_expired(&self, ttl: Duration) -> bool
pub fn is_expired(&self, ttl: Duration) -> bool
Check if the plan has expired
pub fn matches_exact_query(&self, query: &str) -> bool
pub fn needs_replan(&self) -> bool
pub fn record_observation(&mut self, rows_scanned: u64)
Trait Implementations§
Source§impl Clone for CachedPlan
impl Clone for CachedPlan
Source§fn clone(&self) -> CachedPlan
fn clone(&self) -> CachedPlan
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CachedPlan
impl RefUnwindSafe for CachedPlan
impl Send for CachedPlan
impl Sync for CachedPlan
impl Unpin for CachedPlan
impl UnsafeUnpin for CachedPlan
impl UnwindSafe for CachedPlan
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request