Track whether an optimization decision was cost-based#20990
Merged
mlyublena merged 1 commit intoprestodb:masterfrom Oct 10, 2023
Merged
Track whether an optimization decision was cost-based#20990mlyublena merged 1 commit intoprestodb:masterfrom
mlyublena merged 1 commit intoprestodb:masterfrom
Conversation
mlyublena
commented
Oct 2, 2023
Contributor
Author
There was a problem hiding this comment.
cleaned up the output to be sorted and de-duplicated
jainxrohit
reviewed
Oct 3, 2023
presto-main/src/main/java/com/facebook/presto/sql/planner/planPrinter/TextRenderer.java
Outdated
Show resolved
Hide resolved
...va/com/facebook/presto/sql/planner/iterative/rule/PushPartialAggregationThroughExchange.java
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
I wonder if caller can pass this information rather setting this here?
Contributor
There was a problem hiding this comment.
Wouldn't this disjunction cause all cost-based optimizers to be logged? Currently it does not matter since none of the PlanOptimizers are cost-based, but if that should change this would not be correct
Contributor
Author
There was a problem hiding this comment.
I think you're right, I'll change it to only log isCostBased if the optimization triggered
Contributor
|
Add these as well? DetermineSemiJoinDistributionType |
pranjalssh
approved these changes
Oct 5, 2023
...va/com/facebook/presto/sql/planner/iterative/rule/PushPartialAggregationThroughExchange.java
Outdated
Show resolved
Hide resolved
2ba92de to
4eb770b
Compare
Some of Presto's optimizers are heuristic, while others are cost-based.
This change allows tracking which optimizers were driven by a cost-based decision (independent of whether the cost was estimated or supplied by HBO).
This information is added to PlanOptimizerInformation and can be seen in the explain plan when verbose_optimizer_info_enabled=true, for example:
presto:tpch> explain select lineitem.linenumber,count(*) from orders join lineitem on (lineitem.orderkey=orders.orderkey) group by linenumber;
Query Plan
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Output[PlanNodeId 12][linenumber, _col1] => [linenumber:integer, count:bigint]
_col1 := count (1:36)
- RemoteStreamingExchange[PlanNodeId 297][GATHER] => [linenumber:integer, count:bigint]
- Project[PlanNodeId 406][projectLocality = LOCAL] => [linenumber:integer, count:bigint]
- Aggregate(FINAL)[linenumber][$hashvalue][PlanNodeId 7] => [linenumber:integer, $hashvalue:bigint, count:bigint]
count := "presto.default.count"((count_15)) (1:36)
- LocalExchange[PlanNodeId 355][HASH][$hashvalue] (linenumber) => [linenumber:integer, count_15:bigint, $hashvalue:bigint]
- RemoteStreamingExchange[PlanNodeId 361][REPARTITION][$hashvalue_16] => [linenumber:integer, count_15:bigint, $hashvalue_16:bigint]
- Aggregate(PARTIAL)[linenumber][$hashvalue_22][PlanNodeId 359] => [linenumber:integer, $hashvalue_22:bigint, count_15:bigint]
count_15 := "presto.default.count"(*) (1:36)
- Project[PlanNodeId 405][projectLocality = LOCAL] => [linenumber:integer, $hashvalue_22:bigint]
Estimates: {source: CostBasedSourceInfo, rows: 58490 (799.67kB), cpu: 7320844.01, memory: 270000.00, network: 1654025.00}
$hashvalue_22 := combine_hash(BIGINT'0', COALESCE($operator$hash_code(linenumber), BIGINT'0')) (1:119)
- InnerJoin[PlanNodeId 271][("orderkey_0" = "orderkey")][$hashvalue_17, $hashvalue_19] => [linenumber:integer]
Estimates: {source: CostBasedSourceInfo, rows: 58490 (799.67kB), cpu: 6501977.37, memory: 270000.00, network: 1654025.00}
Distribution: PARTITIONED
- RemoteStreamingExchange[PlanNodeId 294][REPARTITION][$hashvalue_17] => [orderkey_0:bigint, linenumber:integer, $hashvalue_17:bigint]
Estimates: {source: CostBasedSourceInfo, rows: 60175 (822.71kB), cpu: 3610500.00, memory: 0.00, network: 1384025.00}
- ScanProject[PlanNodeId 1,403][table = TableHandle {connectorId='hive', connectorHandle='HiveTableHandle{schemaName=tpch, tableName=lineitem, analyzePartitionValues=Optional.empty}', layout='Optional[tpch.lineitem{}]'}, projectLocality = LOCAL] => [orderkey_0:bigint, linenumber:integer, $hashvalue_18:bigint]
Estimates: {source: CostBasedSourceInfo, rows: 60175 (822.71kB), cpu: 842450.00, memory: 0.00, network: 0.00}/{source: CostBasedSourceInfo, rows: 60175 (822.71kB), cpu: 2226475.00, memory: 0.00, network: 0.00}
$hashvalue_18 := combine_hash(BIGINT'0', COALESCE($operator$hash_code(orderkey_0), BIGINT'0')) (1:62)
LAYOUT: tpch.lineitem{}
orderkey_0 := orderkey:bigint:0:REGULAR (1:62)
linenumber := linenumber:int:3:REGULAR (1:62)
- LocalExchange[PlanNodeId 338][HASH][$hashvalue_19] (orderkey) => [orderkey:bigint, $hashvalue_19:bigint]
Estimates: {source: CostBasedSourceInfo, rows: 15000 (205.08kB), cpu: 945000.00, memory: 0.00, network: 270000.00}
- RemoteStreamingExchange[PlanNodeId 295][REPARTITION][$hashvalue_20] => [orderkey:bigint, $hashvalue_20:bigint]
Estimates: {source: CostBasedSourceInfo, rows: 15000 (205.08kB), cpu: 675000.00, memory: 0.00, network: 270000.00}
- ScanProject[PlanNodeId 0,404][table = TableHandle {connectorId='hive', connectorHandle='HiveTableHandle{schemaName=tpch, tableName=orders, analyzePartitionValues=Optional.empty}', layout='Optional[tpch.orders{}]'}, projectLocality = LOCAL] => [orderkey:bigint, $hashvalue_21:bigint]
Estimates: {source: CostBasedSourceInfo, rows: 15000 (205.08kB), cpu: 135000.00, memory: 0.00, network: 0.00}/{source: CostBasedSourceInfo, rows: 15000 (205.08kB), cpu: 405000.00, memory: 0.00, network: 0.00}
$hashvalue_21 := combine_hash(BIGINT'0', COALESCE($operator$hash_code(orderkey), BIGINT'0')) (1:50)
LAYOUT: tpch.orders{}
orderkey := orderkey:bigint:0:REGULAR (1:50)
Triggered optimizers: [AddLocalExchanges, ApplyConnectorOptimization, HashGenerationOptimizer, PickTableLayoutWithoutPredicate, PruneJoinChildrenColumns, PruneJoinColumns, PruneProjectColumns, PruneTableScanColumns, PruneUnreferencedOutputs, PushPartialAggregationThroughExchange, RemoveRedundantDistinctAggregation, RemoveRedundantIdentityProjections, ReorderJoins, SetFlatteningOptimizer, SimplifyPlanWithEmptyInput, StatsRecordingPlanOptimizer, UnaliasSymbolReferences]
Applicable optimizers: [AddNotNullFiltersToJoinNode, KeyBasedSampler, MergePartialAggregationsWithFilter, PushPartialAggregationThroughJoin]
Cost-based optimizers: [PushPartialAggregationThroughExchange(CBO), ReorderJoins(CBO)]
4eb770b to
1108b01
Compare
6 tasks
6 tasks
26 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some of Presto's optimizers are heuristic, while others are cost-based. This change allows tracking which optimizers were driven by a cost-based decision (independent of whether the cost was estimated or supplied by HBO). This information is added to PlanOptimizerInformation and can be seen in the explain plan when verbose_optimizer_info_enabled=true, for example:
Note: currently we don't track whether the cost came from HBO or through cost estimation, only that the decision was cost-driven. We already have a change that tracks what the source of the cost estimation is, so we can potentially intersect the two to find this information. I could potentially reconsider and track and log this information directly here.
Description
Motivation and Context
Impact
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.