Skip to main content

sample_pk_bounds

Function sample_pk_bounds 

Source
async fn sample_pk_bounds(
    config: &RawSourceCreationConfig,
    connection_config: &Config,
    task_name: &str,
    tables: &BTreeMap<MySqlTableName, Vec<SourceOutputInfo>>,
    metrics: &MySqlSnapshotMetrics,
) -> Result<(BTreeMap<MySqlTableName, Option<PkBoundaries>>, BTreeMap<MySqlTableName, u64>), TransientError>
Expand description

For every table, read the row count (exact only for small tables) and, for a supported single-column primary key, compute the PK-range split boundaries, concurrently over at most worker_count connections. None bounds means single-worker fallback for that table. The counts are reused for both the sampling stride and the snapshot size gauge. Snapshot size gauge is a metric for the snapshot size used to report how many rows we need to process. “Sampling stride” refers to the number of rows we use to page through the table to find roughly evenly spaced primary keys to use as partition boundaries.