Class Approximation
- All Implemented Interfaces:
ApproximationDriver
To obtain an appropriate sample probability, first a target number of rows
is set. This is determined via the ApproximationSettings.
Next, the total number of rows in the source index is counted via the subplan
sourceCountSubPlan(). This plan always executes fast. When
there are no commands that can change the number of rows, the sample
probability can be directly computed as a ratio of the target number of rows
and this total number.
In the presence of commands that can change the number of rows (e.g. filtering),
another step is needed. The first goal is to find a sample probability that
leads to approximately ROW_COUNT_FOR_COUNT_ESTIMATION rows,
and when this probability is found, a sample probability leading to the target
number of rows is computed.
This is done by setting the initial sample probability to the ratio of
ROW_COUNT_FOR_COUNT_ESTIMATION and the total number
of rows in the source index, and a number of rows is sampled with the subplan
countSubPlan(double). As long as the sampled number of rows is too
small, the probability is increased until a good probability is reached. This
final probability is used to compute the probability using for approximating
the original query.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the first subplan to execute for approximation, or null if the main plan can be executed directly.newMainPlan(LogicalPlan mainPlan, Result result) Processes a subplan result and returns the main plan with placeholders substituted when this calibration step is complete.
-
Method Details
-
firstSubPlan
Returns the first subplan to execute for approximation, or null if the main plan can be executed directly.- Specified by:
firstSubPlanin interfaceApproximationDriver
-
newMainPlan
Description copied from interface:ApproximationDriverProcesses a subplan result and returns the main plan with placeholders substituted when this calibration step is complete.- Specified by:
newMainPlanin interfaceApproximationDriver
-