pub struct PlanCache {
pub hits: u64,
pub misses: u64,
/* private fields */
}Expand description
LRU-ish plan cache keyed by canonical query hash.
Mission F: uses FxHashMap. The keys are u64 hashes (already pre-hashed
by canonicalize), so SipHash is pure overhead — Fx is much cheaper for
the integer-keyed lookup.
Fields§
§hits: u64§misses: u64Implementations§
Source§impl PlanCache
impl PlanCache
pub fn new(capacity: usize) -> Self
Sourcepub fn insert(&mut self, hash: u64, plan: PlanNode)
pub fn insert(&mut self, hash: u64, plan: PlanNode)
Store a planned query under its canonical hash. The plan can have any literal values inside it — those will be overwritten on hit.
Sourcepub fn get_with_substitution(
&mut self,
hash: u64,
literals: &[Literal],
) -> Option<PlanNode>
pub fn get_with_substitution( &mut self, hash: u64, literals: &[Literal], ) -> Option<PlanNode>
Look up a plan by canonical hash and return a clone with the new
literals substituted into every Expr::Literal slot in source
order.
Returns Some(plan) on a hit and bumps self.hits. Returns None
on a miss and bumps self.misses. Returning None instead of
reaching for the planner here keeps this module dependency-free
from planner — the engine handles the miss path.
The substitution is done on a clone of the cached plan, not the stored copy. The cached plan stays pristine for the next call.