<!-- llms-explorer concept facts · https://llms-explorer.com/tree/sampling-ce-accuracy-under-sparse-sample-matches/ · pack 2026-10-31 · ~1374 tokens -->

# Sampling CE accuracy under sparse sample matches

> Source-anchored research for Sampling CE accuracy under sparse sample matches. Run status: COMPLETED.

Parent: [ceSource cardinality estimation (sampling vs heuristics)](https://llms-explorer.com/tree/cesource-cardinality-estimation-sampling-vs-heuristics/) · 5 facets · 12 facts · page: https://llms-explorer.com/tree/sampling-ce-accuracy-under-sparse-sample-matches/

## How it works

- Sparse qualifying samples can produce unstable MongoDB estimates: SERVER-99095 reports 1,000 explains on 50,000 unique values with one true match, yielding 995 zero estimates and five estimates of 130.2109375. The reporter warns that this can cause plan switching; the ticket does not demonstrate measured production plan flips. (low confidence) — [source](https://jira.mongodb.org/browse/SERVER-99095)
- Sampling accuracy depends on sample size and predicate selectivity. For independent uniform draws with replacement, expected hits equal m*p; deriving from the cited Bernoulli model, the chance of no hit is (1-p)^m. When m*p is small, zero sampled hits can coexist with a nonempty result. (high confidence) — [source](https://arxiv.org/pdf/2108.02715)

## Measurements and reference values

- For independent uniform sampling with replacement and true selectivity p, expected sampled matches are m*p. Derived from the cited Bernoulli model, P(zero matches)=(1-p)^m: p=0.0001 and m=1000 give about 90.5%. This calculation excludes dependent sampling. (low confidence) — [source](https://arxiv.org/pdf/2108.02715)

## Problems, failure modes and limitations

- The raw extrapolation formula N*h/m gives zero for zero qualifying sampled rows and N/m for one qualifying row. These are extrapolations, not true-match counts. The CIDR paper’s practical ESTS convention instead uses selectivity 1/m for zero qualifying samples, while the arXiv Q-error analysis clamps estimated and true cardinalities to at least one to avoid division by zero. (high confidence) — [source](https://www.vldb.org/cidrdb/2020/alpha-to-omega-the-greek-alphabet-of-sampling.html)
- SERVER-100408 proposes investigating a minimum qualifying-hit count of ten, returning an error to permit another estimator, or attaching a reliability metric. These are proposals, not established shipped behavior. Its page lists an unresolved resolution and no fix version, with an update date of 2026-04-06. (low confidence) (verified as of 2026-04-06) — [source](https://jira.mongodb.org/browse/SERVER-100408)
- Unbiasedness or consistency alone does not guarantee accurate estimates within a finite sampling budget. Hu and Motik report that complex graph queries with skewed distributions can fail to obtain valid samples and return zero, despite the convergence properties of sampling estimators. This corroborates the general failure mode, not MongoDB-specific join behavior. (medium confidence) — [source](https://krr-nas.cs.ox.ac.uk/2024/cardinality-sampling/paper.pdf)
- Sampling precision depends on sample size and selectivity. For independent single-table sampling with replacement, the cited Q-error bounds do not depend on total table size. A fixed sampling fraction is therefore not the only accuracy criterion. (high confidence) — [source](https://www.vldb.org/cidrdb/2020/alpha-to-omega-the-greek-alphabet-of-sampling.html)
- For a filtered sample containing no matching tuples, extrapolation supplies no observed matching rows with which to characterize the filtered subset. The SIGMOD authors specifically warn that this leaves no information about how that subset interacts with other tables; this join-related limitation must not be presented as a measured MongoDB single-collection result. (medium confidence) — [source](https://www.vldb.org/cidrdb/2020/alpha-to-omega-the-greek-alphabet-of-sampling.html)

## Comparisons and alternatives

- Treat the ticket's fewer-than-ten qualifying-documents threshold as an engineering warning rather than a universal statistical guarantee. Formal bounds depend on selectivity, sample size and the requested Q-error/confidence; simply reaching ten hits does not establish every desired accuracy target. (medium confidence) — [source](https://jira.mongodb.org/browse/SERVER-100408)
- Increasing sampling effort trades planning time for accuracy; an alternative estimator should be evaluated rather than assumed superior. MongoDB's sparse-match report explicitly cautions that heuristic CE might be worse, while graph-query research emphasizes the need to balance estimation speed against accuracy. (medium confidence) — [source](https://jira.mongodb.org/browse/SERVER-99095)
- Adaptive sampling trades optimization cost against accuracy. The Wisconsin survey illustrates that a predicate matching one of a million rows can require extremely many draws to meet a relative-error goal. Its sanity-bound alternative limits sampling but provides an error guarantee relative to the maximum possible result size instead of the actual result size. (low confidence) — [source](https://pages.cs.wisc.edu/~wentaowu/courses/cs787.pdf)

## Facts and statements

- Sequential sampling uses observations collected so far to decide whether to continue. The surveyed stopping rule requires positive estimated variance, and its asymptotic confidence argument assumes consistency and a normal approximation; an all-zero prefix is not by itself evidence of precise estimation. (low confidence) — [source](https://pages.cs.wisc.edu/~wentaowu/courses/cs787.pdf)
