-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[CALCITE-2204] Use BFS for propagating cost #643
Conversation
|
||
void hierarchicalPropagateImprovement(VolcanoPlanner planner, RelMetadataQuery mq, | ||
RelSubset subset, RelNode rel, Set<RelSubset> activeSet) { | ||
Stack<Pair<RelNode, RelSubset>> propagateStack = new Stack<>(); |
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.
Stack class is very legacy, it extends Vector, maybe we can use some better util 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.
ok, It only need Queue for FIFO instead of Stack
@@ -319,9 +321,67 @@ RelNode buildCheapestPlan(VolcanoPlanner planner) { | |||
*/ | |||
void propagateCostImprovements(VolcanoPlanner planner, RelMetadataQuery mq, | |||
RelNode rel, Set<RelSubset> activeSet) { | |||
// for (RelSubset subset : set.subsets) { |
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.
Nit: drop comments
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.
ok,I will
@eolivelli It use ArrayDeque instead of Stack. Please review again. Thanks |
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.
Thank you for addressing my comments @LeoWangLZ for me is OK.
Unfortunately I have not enough information to say that this change is good, I did not run tests locally.
my +1 is non-binding, I did only a simple code review
@eolivelli Thanks again. I think Julian Hyde will review it |
could you add some test, say what scenario does this enhancement addresses, there are descriptions in your PR, but your implementation need to be guarded anyway. |
@@ -360,6 +359,28 @@ void propagateCostImprovements0(VolcanoPlanner planner, RelMetadataQuery mq, | |||
} | |||
} | |||
|
|||
void hierarchicalPropagateImprovement(VolcanoPlanner planner, RelMetadataQuery mq, |
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.
@LeoWangLZ what do you think about documenting BFS approach with examples?
I wonder how this plays with #552 which seems to update @LeoWangLZ , have you seen that? |
80f411d
to
ca27fe9
Compare
Close it because it has been fixed in e435954. |
In function propagateCostImprovements0, This subset is already in the chain being propagated to. This means that the graph is cyclic, and therefore the cost of this relational expression - not this subset - must be infinite. it may miss the best plan. I think we should change the way of propagation. now the algorithm like pre-order, it may use Breadth-first Search.
like
now the order of propagation is input->parent11->parent22->parent12.
use BFS, it maybe input->parent11->parent12->parent21->parent22.