pub enum SamplingStrategy {
Full,
Random {
limit: usize,
},
ReservoirPK {
sample_size: usize,
pk: String,
},
TableSample {
percentage: f32,
limit: usize,
},
}Expand description
Sampling strategy selection based on table size
Variants§
Full
Full table scan - when sample_size >= row_count No randomization, deterministic results
Random
Random sampling for smaller tables (< 100k rows) Simple ORDER BY Random() LIMIT N
ReservoirPK
Reservoir sampling for medium tables (100K - 10M rows) uses primary key based random sampling for better performance
TableSample
TABLESAMPLE for larger tables (> 10M rows) Postgresql’s built in sampling - fast and no table locks
Implementations§
Source§impl SamplingStrategy
impl SamplingStrategy
Sourcepub async fn auto_select(
pool: &PgPool,
schema: &str,
table: &str,
estimated_rows: Option<i64>,
sample_size: usize,
) -> Result<Self, Error>
pub async fn auto_select( pool: &PgPool, schema: &str, table: &str, estimated_rows: Option<i64>, sample_size: usize, ) -> Result<Self, Error>
Auto select the best sampling strat based on table size
§Strat selection
- < 100k rows: Random sampling
- 100k - 10M rows: Resevoir sampling with PK
- 10M rows: TABLESAMPLE
Sourcepub fn max_samples(&self) -> usize
pub fn max_samples(&self) -> usize
Get the max number of samples that this strat should return
Trait Implementations§
Source§impl Clone for SamplingStrategy
impl Clone for SamplingStrategy
Source§fn clone(&self) -> SamplingStrategy
fn clone(&self) -> SamplingStrategy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SamplingStrategy
impl Debug for SamplingStrategy
Source§impl PartialEq for SamplingStrategy
impl PartialEq for SamplingStrategy
impl StructuralPartialEq for SamplingStrategy
Auto Trait Implementations§
impl Freeze for SamplingStrategy
impl RefUnwindSafe for SamplingStrategy
impl Send for SamplingStrategy
impl Sync for SamplingStrategy
impl Unpin for SamplingStrategy
impl UnwindSafe for SamplingStrategy
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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>
Wrap the input message
T in a tonic::Request