pub struct RelationStats {
pub rel_id: RelId,
pub cardinality: u64,
pub byte_size: u64,
pub column_stats: Vec<ColumnStats>,
pub prefix_degrees: Vec<PrefixDegreeStats>,
pub key_heats: Vec<KeyHeatStats>,
pub heat: f32,
pub last_access: u64,
pub has_index: bool,
}Expand description
GPU-resident relation statistics.
Tracks cardinality, memory usage, access patterns, and column-level statistics for relations stored on the GPU. These statistics drive optimizer cost models and solver heuristics for efficient query execution.
Fields§
§rel_id: RelIdUnique identifier for the relation
cardinality: u64Estimated number of rows in the relation
byte_size: u64Estimated total size in bytes on GPU
column_stats: Vec<ColumnStats>Per-column statistics
prefix_degrees: Vec<PrefixDegreeStats>Per-column prefix fan-out statistics for trie-style WCOJ planning.
key_heats: Vec<KeyHeatStats>Per-column key heat/skew summaries for skew-aware WCOJ planning.
heat: f32Access heat for LRU-style eviction (exponential moving average)
last_access: u64Unix timestamp of last access
has_index: boolWhether an index exists for this relation
Implementations§
Source§impl RelationStats
impl RelationStats
Sourcepub fn update_cardinality(&mut self, rows: u64)
pub fn update_cardinality(&mut self, rows: u64)
Updates the cardinality (row count) of the relation.
This should be called after bulk loads, inserts, or when statistics are refreshed from the actual GPU-resident data.
§Arguments
rows- The new cardinality estimate
Sourcepub fn update_byte_size(&mut self, bytes: u64)
pub fn update_byte_size(&mut self, bytes: u64)
Updates the byte size estimate for the relation.
§Arguments
bytes- The estimated total size in bytes
Sourcepub fn record_access(&mut self)
pub fn record_access(&mut self)
Records an access to this relation, updating heat and timestamp.
Uses an exponential moving average for heat calculation:
heat = heat * 0.9 + 0.1
This causes frequently accessed relations to maintain high heat while infrequently accessed ones cool down over time.
Sourcepub fn decay_heat(&mut self, factor: f32)
pub fn decay_heat(&mut self, factor: f32)
Decays the heat by a multiplicative factor.
This should be called periodically (e.g., during garbage collection or memory pressure events) to allow unused relations to cool down.
§Arguments
factor- Multiplicative decay factor (typically 0.0 to 1.0)
Sourcepub fn add_column(&mut self, col_stats: ColumnStats)
pub fn add_column(&mut self, col_stats: ColumnStats)
Sourcepub fn get_column(&self, col_idx: usize) -> Option<&ColumnStats>
pub fn get_column(&self, col_idx: usize) -> Option<&ColumnStats>
Sourcepub fn get_column_mut(&mut self, col_idx: usize) -> Option<&mut ColumnStats>
pub fn get_column_mut(&mut self, col_idx: usize) -> Option<&mut ColumnStats>
Sourcepub fn add_prefix_degree(&mut self, prefix_degree: PrefixDegreeStats)
pub fn add_prefix_degree(&mut self, prefix_degree: PrefixDegreeStats)
Adds prefix-degree statistics for a join-key column.
Existing entries for the same column are retained; consumers use the first matching entry so snapshots can preserve historical observations.
Sourcepub fn get_prefix_degree(&self, col_idx: usize) -> Option<&PrefixDegreeStats>
pub fn get_prefix_degree(&self, col_idx: usize) -> Option<&PrefixDegreeStats>
Gets prefix-degree statistics by column index.
Sourcepub fn add_key_heat(&mut self, key_heat: KeyHeatStats)
pub fn add_key_heat(&mut self, key_heat: KeyHeatStats)
Adds key-heat statistics for a join-key column.
This is distinct from relation-level RelationStats::heat: relation heat
tracks access frequency, while key heat tracks per-key skew for a column.
Sourcepub fn get_key_heat(&self, col_idx: usize) -> Option<&KeyHeatStats>
pub fn get_key_heat(&self, col_idx: usize) -> Option<&KeyHeatStats>
Gets key-heat statistics by column index.
Trait Implementations§
Source§impl Clone for RelationStats
impl Clone for RelationStats
Source§fn clone(&self) -> RelationStats
fn clone(&self) -> RelationStats
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more