Skip to main content

Statistics

Struct Statistics 

Source
pub struct Statistics { /* private fields */ }

Implementations§

Source§

impl Statistics

Source

pub fn new() -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, table: &str, column: &str) -> Option<&ColumnStats>

Source

pub fn iter(&self) -> impl Iterator<Item = (&(String, String), &ColumnStats)>

Iterate ((table, column), stats) in deterministic alphabetical order. Used by SELECT * FROM spg_statistic and by snapshot serialisation.

Source

pub fn set(&mut self, table: String, column: String, stats: ColumnStats)

Replace (or insert) the stats for one (table, column). Called by ANALYZE per column.

Source

pub fn clear_table(&mut self, table: &str)

Drop every row whose table key matches table. Called before re-ANALYZE on a table so columns dropped between analyses don’t leave stale rows behind.

Source

pub fn reset_modified(&mut self, table: &str)

Reset the modified-row counter for table. Called at the end of ANALYZE so v6.2.1 auto-analyze starts a fresh window.

Source

pub fn record_modifications(&mut self, table: &str, n: u64)

Bump the modified-row counter. The engine’s exec_insert / exec_update / exec_delete paths feed this hook so v6.2.1 auto-analyze can read it.

Source

pub fn modified_since_last_analyze(&self, table: &str) -> u64

Source

pub fn version(&self) -> u64

v6.3.1 — current monotonic version. Plan cache snapshots this at prepare time; lookup compares and evicts on mismatch.

Source

pub fn bump_version(&mut self)

v6.3.1 — bumps the version. Called by exec_analyze after a successful ANALYZE on any table.

Source

pub fn serialize(&self) -> Vec<u8>

Format (each block little-endian): [u16 num_columns] for each column: [u16 table_len][table bytes] [u16 col_len][col bytes] [f32 null_frac] [u64 n_distinct] [u16 num_bounds] for each bound: [u16 b_len][b bytes] [u16 num_modified_entries] for each: [u16 t_len][t bytes][u64 modified_count]

Source

pub fn deserialize(buf: &[u8]) -> Result<Self, StatisticsError>

Trait Implementations§

Source§

impl Clone for Statistics

Source§

fn clone(&self) -> Statistics

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Statistics

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Statistics

Source§

fn default() -> Statistics

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Statistics

Source§

fn eq(&self, other: &Statistics) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Statistics

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.