Skip to content

Commit 68dde4f

Browse files
committed
reduce trial count to 2
1 parent d592461 commit 68dde4f

File tree

1 file changed

+3
-3
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/approximate

1 file changed

+3
-3
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/approximate/Approximate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public record QueryProperties(boolean canDecreaseRowCount, boolean canIncreaseRo
245245
/**
246246
* The number of times (trials) the sampled rows are divided into buckets.
247247
*/
248-
private static final int TRIAL_COUNT = 3;
248+
private static final int TRIAL_COUNT = 2;
249249

250250
/**
251251
* The number of buckets to use for computing confidence intervals.
@@ -499,7 +499,7 @@ private ActionListener<Result> countListener(double sampleProbability, ActionLis
499499
return listener.delegateFailureAndWrap((countListener, countResult) -> {
500500
long rowCount = rowCount(countResult);
501501
logger.debug("countPlan result (p={}): {} rows", sampleProbability, rowCount);
502-
double newSampleProbability = sampleProbability * SAMPLE_ROW_COUNT / Math.max(1, rowCount);
502+
double newSampleProbability = Math.min(1.0, sampleProbability * SAMPLE_ROW_COUNT / Math.max(1, rowCount));
503503
if (rowCount <= SAMPLE_ROW_COUNT / 2 && newSampleProbability < 1.0) {
504504
runner.run(
505505
toPhysicalPlan.apply(countPlan(newSampleProbability)),
@@ -573,7 +573,7 @@ private long rowCount(Result countResult) {
573573
* </pre>
574574
*/
575575
private LogicalPlan approximatePlan(double sampleProbability) {
576-
if (sampleProbability >= 1.0) {
576+
if (sampleProbability == 1.0) {
577577
logger.debug("using original plan (too few rows)");
578578
return logicalPlan;
579579
}

0 commit comments

Comments
 (0)