Skip to content

Conversation

@LiBinfeng-01
Copy link
Contributor

@LiBinfeng-01 LiBinfeng-01 commented Oct 15, 2024

pick: #35925 #39715 #40167 #40958
Add feat of force use/nouse cbo rule hint and fix pr

introduce
when not using this hint, cbo rules like INFER_SET_OPERATOR_DISTINCT would generate two plans and compare their cost
and nereids optimizer would decide which is better. But when we want to control the behavior of cbo rules we could use this force cbo rule hint
usage example
explain shape plan
select /*+ USE_CBO_RULE(INFER_SET_OPERATOR_DISTINCT) */
*
from t1
union
select * from t2;
the USE_CBO_RULE(INFER_SET_OPERATOR_DISTINCT) hint would force rule INFER_SET_OPERATOR_DISTINCT to be used
and generate plan like, which hashAgg below union is generated by this rule:

-- !with_hint_union_distinct --
----hashAgg[GLOBAL]
--------hashAgg[LOCAL]
----------PhysicalUnion
--------------hashAgg[LOCAL]
----------------PhysicalOlapScan[t1]
--------------hashAgg[LOCAL]
----------------PhysicalOlapScan[t2]
Hint log:
Used: INFER_SET_OPERATOR_DISTINCT
UnUsed:
SyntaxError:
When we want to force disable this rule, we could use
explain shape plan select /*+ NO_USE_CBO_RULE(INFER_SET_OPERATOR_DISTINCT) */ * from t1 union select * from t2;
which would generate plan with this rule:

-- !with_hint_no_union_distinct --
----hashAgg[GLOBAL]
--------hashAgg[LOCAL]
----------PhysicalUnion
--------------PhysicalOlapScan[t1]
--------------PhysicalOlapScan[t2]
Hint log:
Used: NO_INFER_SET_OPERATOR_DISTINCT
UnUsed:
SyntaxError:
change sessionvariable enableNereidsRules to varType.remove

Add feat of force use/nouse cbo rule hint

introduce
when not using this hint, cbo rules like INFER_SET_OPERATOR_DISTINCT would generate two plans and compare their cost
and nereids optimizer would decide which is better. But when we want to control the behavior of cbo rules we could use this force cbo rule hint
usage example
explain shape plan
select /*+ USE_CBO_RULE(INFER_SET_OPERATOR_DISTINCT) */
*
from t1
union
select * from t2;
the USE_CBO_RULE(INFER_SET_OPERATOR_DISTINCT) hint would force rule INFER_SET_OPERATOR_DISTINCT to be used
and generate plan like, which hashAgg below union is generated by this rule:

-- !with_hint_union_distinct --
----hashAgg[GLOBAL]
--------hashAgg[LOCAL]
----------PhysicalUnion
--------------hashAgg[LOCAL]
----------------PhysicalOlapScan[t1]
--------------hashAgg[LOCAL]
----------------PhysicalOlapScan[t2]
Hint log:
Used: INFER_SET_OPERATOR_DISTINCT
UnUsed:
SyntaxError:
When we want to force disable this rule, we could use

explain shape plan select /*+ NO_USE_CBO_RULE(INFER_SET_OPERATOR_DISTINCT) */ * from t1 union select * from t2;
which would generate plan with this rule:

-- !with_hint_no_union_distinct --
----hashAgg[GLOBAL]
--------hashAgg[LOCAL]
----------PhysicalUnion
--------------PhysicalOlapScan[t1]
--------------PhysicalOlapScan[t2]
Hint log:
Used: NO_INFER_SET_OPERATOR_DISTINCT
UnUsed:
SyntaxError:
change sessionvariable enableNereidsRules to varType.remove
@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@LiBinfeng-01
Copy link
Contributor Author

run buildall

@LiBinfeng-01
Copy link
Contributor Author

run buildall

@LiBinfeng-01 LiBinfeng-01 changed the title [Feat](Nereids) support use cbo rule hint #35925 #39715 [Feat](Nereids) support use cbo rule hint #35925 #39715 #41331 Oct 17, 2024
@LiBinfeng-01 LiBinfeng-01 changed the title [Feat](Nereids) support use cbo rule hint #35925 #39715 #41331 [Feat](Nereids) support use cbo rule hint #35925 #39715 #40958 Oct 17, 2024
support hint like:
/*+ no_use_mv(tablename mvname) / which forbid tablename(indexname) to
be choose
or /+ use_mv(tablename mvname) */ which choose specific materialize view
…che#40958)

isLeading in cascade context means do we have leading in this scope
isLeadingDisableJoinReorder means does leading used
we need to copy it after analyze outerside of cte
@LiBinfeng-01 LiBinfeng-01 changed the title [Feat](Nereids) support use cbo rule hint #35925 #39715 #40958 [Feat](Nereids) support use cbo rule hint #35925 #39715 #40167#40958 Oct 17, 2024
@LiBinfeng-01
Copy link
Contributor Author

run buildall

@morrySnow morrySnow merged commit 80d7523 into apache:branch-2.1 Oct 17, 2024
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.

3 participants