Skip to content

Commit

Permalink
add one space and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Apr 20, 2022
1 parent f391ae5 commit 5d1ed22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions executor/builder.go
Expand Up @@ -2474,11 +2474,11 @@ func (b *executorBuilder) buildAnalyzeSamplingPushdown(task plannercore.AnalyzeC
}

// getAdjustedSampleRate calculate the sample rate by the table size. If we cannot get the table size. We use the 0.001 as the default sample rate.
// From the paper "Random sampling for histogram construction: how much is enough?"'sCorollary 1 to Theorem 5,
// From the paper "Random sampling for histogram construction: how much is enough?"'s Corollary 1 to Theorem 5,
// for a table size n, histogram size k, maximum relative error in bin size f, and error probability gamma,
// the minimum random sample size is
// r = 4 * k * ln(2*n/gamma) / f^2
// If we take f = 0.5, gamma = 0.0, n =1e6, we would got r = 305.82* k.
// If we take f = 0.5, gamma = 0.01, n =1e6, we would got r = 305.82* k.
// Since the there's log function over the table size n, the r grows slowly when the n increases.
// If we take n = 1e12, a 300*k sample still gives <= 0.66 bin size error with probability 0.99.
// So if we don't consider the top-n values, we can keep the sample size at 300*256.
Expand Down

0 comments on commit 5d1ed22

Please sign in to comment.