pub struct ColumnStatistics {
pub row_count: Option<u64>,
pub null_count: Option<u64>,
pub min_value: Option<String>,
pub max_value: Option<String>,
pub distinct_count: Option<u64>,
pub collected_at_secs: Option<u64>,
}Expand description
Optional statistics for a table column (or the whole table).
Fields§
§row_count: Option<u64>Total number of rows in the table, if known.
null_count: Option<u64>Number of null values in the column, if known.
min_value: Option<String>String representation of the minimum value, if known.
max_value: Option<String>String representation of the maximum value, if known.
distinct_count: Option<u64>Number of distinct values (NDV) for the column, if known.
Drives join-order cost estimation and broadcast sizing: a column with NDV ≈ 1 is a hot join key, while a column with NDV ≈ row count is a near-unique key (build-side fan-out is high).
collected_at_secs: Option<u64>Wall-clock Unix timestamp (seconds) when these stats were
collected by ANALYZE TABLE. The CBO refuses to use stats
older than stats_max_age_secs to avoid optimising against
stale cardinality information.
Implementations§
Source§impl ColumnStatistics
impl ColumnStatistics
Sourcepub fn with_row_count(self, count: u64) -> Self
pub fn with_row_count(self, count: u64) -> Self
Set the row count.
Sourcepub fn with_null_count(self, count: u64) -> Self
pub fn with_null_count(self, count: u64) -> Self
Set the null count.
Sourcepub fn with_distinct_count(self, ndv: u64) -> Self
pub fn with_distinct_count(self, ndv: u64) -> Self
Set the NDV (number of distinct values) for the column.
Sourcepub fn with_collected_at_secs(self, secs: u64) -> Self
pub fn with_collected_at_secs(self, secs: u64) -> Self
Stamp the wall-clock timestamp (seconds) at which these stats
were collected. Stamped by [analyze_table][crate::analyze::analyze_table]
so the CBO can detect stale stats.
Sourcepub fn equality_selectivity(&self) -> Option<f64>
pub fn equality_selectivity(&self) -> Option<f64>
Selectivity of a single-point equality filter on this column.
1.0 / distinct_count when both are known; otherwise None.
0.0 when distinct_count == 0 (the column is all-null or empty).
Sourcepub fn is_fresh(&self, now_secs: u64, max_age_secs: u64) -> bool
pub fn is_fresh(&self, now_secs: u64, max_age_secs: u64) -> bool
Whether the stats are “fresh” given a current timestamp and a maximum age in seconds.
Stats without a collection timestamp are considered fresh by
default (back-compat for manually-curated stats). Stats older
than max_age_secs are stale.
Trait Implementations§
Source§impl Clone for ColumnStatistics
impl Clone for ColumnStatistics
Source§fn clone(&self) -> ColumnStatistics
fn clone(&self) -> ColumnStatistics
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ColumnStatistics
impl Debug for ColumnStatistics
Source§impl Default for ColumnStatistics
impl Default for ColumnStatistics
Source§fn default() -> ColumnStatistics
fn default() -> ColumnStatistics
impl Eq for ColumnStatistics
Source§impl PartialEq for ColumnStatistics
impl PartialEq for ColumnStatistics
Source§fn eq(&self, other: &ColumnStatistics) -> bool
fn eq(&self, other: &ColumnStatistics) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ColumnStatistics
Auto Trait Implementations§
impl Freeze for ColumnStatistics
impl RefUnwindSafe for ColumnStatistics
impl Send for ColumnStatistics
impl Sync for ColumnStatistics
impl Unpin for ColumnStatistics
impl UnsafeUnpin for ColumnStatistics
impl UnwindSafe for ColumnStatistics
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 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>
T in a tonic::Request