Skip to content

[CALCITE-2204] Use BFS for propagating cost - #643

Closed
LeoWangLZ wants to merge 2 commits into
apache:masterfrom
LeoWangLZ:CALCITE-2204
Closed

[CALCITE-2204] Use BFS for propagating cost#643
LeoWangLZ wants to merge 2 commits into
apache:masterfrom
LeoWangLZ:CALCITE-2204

Conversation

@LeoWangLZ

@LeoWangLZ LeoWangLZ commented Mar 5, 2018

Copy link
Copy Markdown
Contributor

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

parent21,parent22
    parent11, parent12
        input

now the order of propagation is input->parent11->parent22->parent12.
use BFS, it maybe input->parent11->parent12->parent21->parent22.


void hierarchicalPropagateImprovement(VolcanoPlanner planner, RelMetadataQuery mq,
RelSubset subset, RelNode rel, Set<RelSubset> activeSet) {
Stack<Pair<RelNode, RelSubset>> propagateStack = new Stack<>();

Copy link
Copy Markdown
Contributor

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

@LeoWangLZ LeoWangLZ Mar 5, 2018

Copy link
Copy Markdown
Contributor Author

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

*/
void propagateCostImprovements(VolcanoPlanner planner, RelMetadataQuery mq,
RelNode rel, Set<RelSubset> activeSet) {
// for (RelSubset subset : set.subsets) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: drop comments

@LeoWangLZ LeoWangLZ Mar 5, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,I will

@LeoWangLZ LeoWangLZ changed the title [CALCITE-2204]Use BDF for propagating cost [CALCITE-2204]Use BFS for propagating cost Mar 5, 2018
@LeoWangLZ

LeoWangLZ commented Mar 5, 2018

Copy link
Copy Markdown
Contributor Author

@eolivelli It use ArrayDeque instead of Stack. Please review again. Thanks

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

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

@LeoWangLZ

Copy link
Copy Markdown
Contributor Author

@eolivelli Thanks again. I think Julian Hyde will review it

@zinking

zinking commented Mar 29, 2018

Copy link
Copy Markdown
Contributor

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.

}
}

void hierarchicalPropagateImprovement(VolcanoPlanner planner, RelMetadataQuery mq,

Copy link
Copy Markdown

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?

@vlsi

vlsi commented Jan 8, 2019

Copy link
Copy Markdown
Contributor

I wonder how this plays with #552 which seems to update propagateCostImprovements as well.

@LeoWangLZ , have you seen that?

@risdenk risdenk changed the title [CALCITE-2204]Use BFS for propagating cost [CALCITE-2204] Use BFS for propagating cost Feb 28, 2019
@danny0405
danny0405 force-pushed the master branch 2 times, most recently from 80f411d to ca27fe9 Compare November 30, 2019 07:52
@chunweilei

Copy link
Copy Markdown
Contributor

Close it because it has been fixed in e435954.

@chunweilei chunweilei closed this Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants