-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-34922][SQL] Use a relative cost comparison function in the CBO #32014
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
Changes from 1 commit
811c1c9
6c39602
9d69ede
41b46a8
dc87250
2e2d5fb
3ce2db9
a7406e7
cdf7f08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging { | |
| } | ||
|
|
||
| def betterThan(other: JoinPlan, conf: SQLConf): Boolean = { | ||
| val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight + | ||
| BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight) | ||
| val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight + | ||
| BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight) | ||
| thisCost < otherCost | ||
| if (other.planCost.card == 0 || other.planCost.size == 0) { | ||
| false | ||
| } else { | ||
| val relativeRows = BigDecimal(this.planCost.card) / BigDecimal(other.planCost.card) | ||
| val relativeSize = BigDecimal(this.planCost.size) / BigDecimal(other.planCost.size) | ||
| Math.pow(relativeRows.doubleValue(), conf.joinReorderCardWeight) * | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we update the config doc? |
||
| Math.pow(relativeSize.doubleValue(), 1 - conf.joinReorderCardWeight) < 1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this symmetric?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, it's kind of normalize the row count and bytes size with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm not mistaken, then, when the left side of the comparison is
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, after normalization the formula is still |
||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
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.
How about leaving some comments about why we need to use relative values here?
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.
+1
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.
Added some comments to this method.