New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collect plan statistics for explain only by default #1866
Conversation
presto-main/src/main/java/io/prestosql/sql/analyzer/FeaturesConfig.java
Outdated
Show resolved
Hide resolved
38c16a4
to
d5bfca2
Compare
@findepi AC |
699d1ab
to
4184ca2
Compare
presto-main/src/main/java/io/prestosql/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/sql/analyzer/FeaturesConfig.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/sql/analyzer/FeaturesConfig.java
Outdated
Show resolved
Hide resolved
presto-tests/src/test/java/io/prestosql/tests/TestTpchDistributedStats.java
Show resolved
Hide resolved
presto-tests/src/test/java/io/prestosql/tests/TestTpchDistributedStats.java
Outdated
Show resolved
Hide resolved
presto-tests/src/main/java/io/prestosql/tests/statistics/StatisticsAssertion.java
Show resolved
Hide resolved
4184ca2
to
7055a31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AC @findepi
StatsAndCosts statsAndCosts = StatsAndCosts.empty(); | ||
if (collectStatsAndCosts) { | ||
statsAndCosts = StatsAndCosts.create(root, statsProvider, costProvider); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more lines this way
@@ -848,7 +848,7 @@ public Plan createPlan(Session session, @Language("SQL") String sql, List<PlanOp | |||
LogicalPlanner logicalPlanner = new LogicalPlanner(session, optimizers, new PlanSanityChecker(true), idAllocator, metadata, new TypeAnalyzer(sqlParser, metadata), statsCalculator, costCalculator, warningCollector); | |||
|
|||
Analysis analysis = analyzer.analyze(preparedQuery.getStatement()); | |||
return logicalPlanner.plan(analysis, stage); | |||
return logicalPlanner.plan(analysis, stage, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalQueryRunner
is mostly used in tests, therefore it's OK (and actually simpler) to have it collect plan stats always.
7055a31
to
19c657e
Compare
presto-main/src/main/java/io/prestosql/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
@@ -162,6 +163,11 @@ public Plan plan(Analysis analysis) | |||
} | |||
|
|||
public Plan plan(Analysis analysis, Stage stage) | |||
{ | |||
return plan(analysis, stage, analysis.getStatement() instanceof Explain || isCollectPlanStatisticsForAllQueries(session)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since QueryExplainer
passes true
here, do we need to have instanceof
?
i don't like instanceof
.
if this is about EXPLAIN ANALYZE, we should be able to pass this information in some better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is already similar check io/prestosql/execution/SqlQueryExecution.java:410
if this is about EXPLAIN ANALYZE, we should be able to pass this information in some better way.
Maybe there is some other way, but is it worth to trade it for such simple change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this check here for EXPLAIN or EXPLAIN ANALYZE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this check here for EXPLAIN or EXPLAIN ANALYZE?
EXPLAIN
, (any kind of).
// We are not able to calculate stats for PARTIAL aggregations | ||
.setSystemProperty(PREFER_PARTIAL_AGGREGATION, "false") | ||
// Distributed query runner does not collect stats for non-EXPLAIN queries by default | ||
.setSystemProperty(COLLECT_PLAN_STATISTICS_FOR_ALL_QUERIES, "true")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment. I still wonder why we have to set it here, in this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we need them for stats tests, which the class name suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which the class name suggest?
as it is (// Distributed query runner does not collect stats for non-EXPLAIN queries by default
) it just states what the default is, no point in saying it here
i hoped for something more direct, but let it assume it's self-explanatory
presto-tests/src/main/java/io/prestosql/tests/statistics/MetricComparison.java
Outdated
Show resolved
Hide resolved
320833c
to
3b0e30b
Compare
Plan stats collection creates considerable load on Hive metastore (even when CBO is disabled). Therefore is better not to collect stats for plan for non-explain queries
3b0e30b
to
8971d84
Compare
Plan stats collection creates considerable load on
Hive metastore (even when CBO is disabled). Therefore
is better not to collect stats for plan for
non-explain queries