Record stats for AddExchanges and PredicatePushdown
@@ -105,6 +105,7 @@ import com.facebook.presto.sql.planner.optimizations.PlanOptimizer;
import com.facebook.presto.sql.planner.optimizations.PredicatePushDown;
import com.facebook.presto.sql.planner.optimizations.PruneUnreferencedOutputs;
import com.facebook.presto.sql.planner.optimizations.SetFlatteningOptimizer;
+import com.facebook.presto.sql.planner.optimizations.StatsRecordingPlanOptimizer;
import com.facebook.presto.sql.planner.optimizations.TransformCorrelatedSingleRowSubqueryToProject;
import com.facebook.presto.sql.planner.optimizations.TransformQuantifiedComparisonApplyToLateralJoin;
import com.facebook.presto.sql.planner.optimizations.UnaliasSymbolReferences;
@@ -124,6 +125,7 @@ public class PlanOptimizers
{
private final List<PlanOptimizer> optimizers;
private final RuleStatsRecorder ruleStats = new RuleStatsRecorder();
+ private final OptimizerStatsRecorder optimizerStats = new OptimizerStatsRecorder();
private final MBeanExporter exporter;
@Inject
@@ -152,12 +154,14 @@ public class PlanOptimizers
public void initialize()
{
ruleStats.export(exporter);
+ optimizerStats.export(exporter);
}
@PreDestroy
public void destroy()
{
ruleStats.unexport(exporter);
+ optimizerStats.unexport(exporter);
}
public PlanOptimizers(
@@ -219,6 +223,8 @@ public class PlanOptimizers
estimatedExchangesCostCalculator,
new SimplifyExpressions(metadata, sqlParser).rules());
+ PlanOptimizer predicatePushDown = new StatsRecordingPlanOptimizer(optimizerStats, new PredicatePushDown(metadata, sqlParser));
+
builder.add(
// Clean up all the sugar in expressions, e.g. AtTimeZone, must be run before all the other optimizers
new IterativeOptimizer(
@@ -306,7 +312,7 @@ public class PlanOptimizers
new ImplementFilteredAggregations())),
new TransformCorrelatedSingleRowSubqueryToProject(),
new CheckSubqueryNodesAreRewritten(),
- new PredicatePushDown(metadata, sqlParser),
+ predicatePushDown,
new IterativeOptimizer(
ruleStats,
statsCalculator,
@@ -354,7 +360,7 @@ public class PlanOptimizers
statsCalculator,
estimatedExchangesCostCalculator,
ImmutableSet.of(new EliminateCrossJoins())), // This can pull up Filter and Project nodes from between Joins, so we need to push them down again
- new PredicatePushDown(metadata, sqlParser),
+ predicatePushDown,
simplifyOptimizer, // Should be always run after PredicatePushDown
new IterativeOptimizer(
ruleStats,
@@ -385,7 +391,7 @@ public class PlanOptimizers
statsCalculator,
estimatedExchangesCostCalculator,
ImmutableSet.of(new PushTableWriteThroughUnion()))); // Must run before AddExchanges
- builder.add(new AddExchanges(metadata, sqlParser));
+ builder.add(new StatsRecordingPlanOptimizer(optimizerStats, new AddExchanges(metadata, sqlParser)));
}
//noinspection UnusedAssignment
estimatedExchangesCostCalculator = null; // Prevent accidental use after AddExchanges
@@ -397,7 +403,7 @@ public class PlanOptimizers
costCalculator,
ImmutableSet.of(new RemoveEmptyDelete()))); // Run RemoveEmptyDelete after table scan is removed by PickTableLayout/AddExchanges
- builder.add(new PredicatePushDown(metadata, sqlParser)); // Run predicate push down one more time in case we can leverage new information from layouts' effective predicate
+ builder.add(predicatePushDown); // Run predicate push down one more time in case we can leverage new information from layouts' effective predicate
builder.add(simplifyOptimizer); // Should be always run after PredicatePushDown
builder.add(projectionPushDown);
builder.add(inlineProjections);
