Skip to main content

RelationStats

Struct RelationStats 

Source
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: RelId

Unique identifier for the relation

§cardinality: u64

Estimated number of rows in the relation

§byte_size: u64

Estimated 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: f32

Access heat for LRU-style eviction (exponential moving average)

§last_access: u64

Unix timestamp of last access

§has_index: bool

Whether an index exists for this relation

Implementations§

Source§

impl RelationStats

Source

pub fn new(rel_id: RelId) -> Self

Creates new statistics for a relation with default (empty) values.

§Arguments
  • rel_id - The unique identifier for the relation
§Returns

A new RelationStats instance with zero cardinality, no columns, and cold heat.

Source

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
Source

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
Source

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.

Source

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)
Source

pub fn add_column(&mut self, col_stats: ColumnStats)

Adds column statistics for a new column.

§Arguments
  • col_stats - The column statistics to add
Source

pub fn get_column(&self, col_idx: usize) -> Option<&ColumnStats>

Gets column statistics by index.

§Arguments
  • col_idx - The column index
§Returns

A reference to the column statistics if found

Source

pub fn get_column_mut(&mut self, col_idx: usize) -> Option<&mut ColumnStats>

Gets mutable column statistics by index.

§Arguments
  • col_idx - The column index
§Returns

A mutable reference to the column statistics if found

Source

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.

Source

pub fn get_prefix_degree(&self, col_idx: usize) -> Option<&PrefixDegreeStats>

Gets prefix-degree statistics by column index.

Source

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.

Source

pub fn get_key_heat(&self, col_idx: usize) -> Option<&KeyHeatStats>

Gets key-heat statistics by column index.

Source

pub fn estimate_selectivity(&self, estimated_matches: u64) -> f64

Estimates the selectivity for a given predicate cardinality.

§Arguments
  • estimated_matches - The estimated number of matching rows
§Returns

The selectivity as a ratio (0.0 to 1.0)

Trait Implementations§

Source§

impl Clone for RelationStats

Source§

fn clone(&self) -> RelationStats

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RelationStats

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,