-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[enhancement](nereids) improve lots of values in
insert into values
…
… statement (#40202) improve lots of values in `insert into values` statement by bypass NereidsPlanner the main logic is 1. `InsertUtils.normalizePlan` use `FoldConstantRuleOnFE` to reduce the expression, e.g. `values(date(now())` 2. `FastInsertIntoValuesPlanner` skip most of rules to analyze and rewrite `LogicalInlineTable` to `LogicalUnion` or `LogicalOneRowRelation` 3. fast parse date time string without date format 4. getHintMap and normal lexer share the same tokens 5. `set enable_fast_analyze_into_values=false` can force to execute all optimize rules, when we meet some bugs in `FastInsertIntoValuesPlanner` test: insert 1000 rows with 1000 columns, the columns contains int, bigint, decimal(26,7), date, datetime, varchar(10 chinese chars) +---------------------------------+------------------------------------------------------+--------------------------+--------------------------+ |FastInsertIntoValuesPlanner |NereidsPlanner(enable_fast_analyze_into_values=false) |Legacy optimizer in 2.1.6 | Nereids planner in 2.1.6 | +---------------------------------+------------------------------------------------------+--------------------------+--------------------------+ |16s(bottleneck is antlr's lexer) |32s |16s |80s | +---------------------------------+------------------------------------------------------+--------------------------+--------------------------+ If you use FastInsertIntoValuesPlanner with group commit in a transaction, the time can reduce to 12s. TODO: build a custom lexer. in my hand write lexer test, FastInsertIntoValuesPlanner without group commit can reduce 16s to 12s, but it will take more effort: RegularExpression -> NFA -> DFA -> minimal DFA -> Lexer codegen
- Loading branch information
Showing
48 changed files
with
1,217 additions
and
228 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
87 changes: 87 additions & 0 deletions
87
fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundInlineTable.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.apache.doris.nereids.analyzer; | ||
|
||
import org.apache.doris.nereids.exceptions.UnboundException; | ||
import org.apache.doris.nereids.memo.GroupExpression; | ||
import org.apache.doris.nereids.properties.LogicalProperties; | ||
import org.apache.doris.nereids.trees.expressions.Expression; | ||
import org.apache.doris.nereids.trees.expressions.NamedExpression; | ||
import org.apache.doris.nereids.trees.expressions.Slot; | ||
import org.apache.doris.nereids.trees.plans.BlockFuncDepsPropagation; | ||
import org.apache.doris.nereids.trees.plans.Plan; | ||
import org.apache.doris.nereids.trees.plans.PlanType; | ||
import org.apache.doris.nereids.trees.plans.algebra.InlineTable; | ||
import org.apache.doris.nereids.trees.plans.logical.LogicalLeaf; | ||
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; | ||
import org.apache.doris.nereids.util.Utils; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** UnboundInlineTable */ | ||
public class UnboundInlineTable extends LogicalLeaf implements InlineTable, BlockFuncDepsPropagation, UnboundPlan { | ||
private final List<List<NamedExpression>> constantExprsList; | ||
|
||
public UnboundInlineTable(List<List<NamedExpression>> constantExprsList) { | ||
super(PlanType.LOGICAL_UNBOUND_INLINE_TABLE, Optional.empty(), Optional.empty()); | ||
this.constantExprsList = Utils.fastToImmutableList( | ||
Objects.requireNonNull(constantExprsList, "constantExprsList can not be null") | ||
); | ||
} | ||
|
||
public List<List<NamedExpression>> getConstantExprsList() { | ||
return constantExprsList; | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(PlanVisitor<R, C> visitor, C context) { | ||
return visitor.visitUnboundInlineTable(this, context); | ||
} | ||
|
||
@Override | ||
public List<? extends Expression> getExpressions() { | ||
ImmutableList.Builder<Expression> expressions = ImmutableList.builderWithExpectedSize( | ||
constantExprsList.size() * constantExprsList.get(0).size()); | ||
|
||
for (List<NamedExpression> namedExpressions : constantExprsList) { | ||
expressions.addAll(namedExpressions); | ||
} | ||
|
||
return expressions.build(); | ||
} | ||
|
||
@Override | ||
public Plan withGroupExpression(Optional<GroupExpression> groupExpression) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression, | ||
Optional<LogicalProperties> logicalProperties, List<Plan> children) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public List<Slot> computeOutput() { | ||
throw new UnboundException("output"); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundPlan.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.apache.doris.nereids.analyzer; | ||
|
||
import org.apache.doris.nereids.exceptions.UnboundException; | ||
import org.apache.doris.nereids.properties.LogicalProperties; | ||
import org.apache.doris.nereids.properties.UnboundLogicalProperties; | ||
import org.apache.doris.nereids.trees.expressions.Slot; | ||
import org.apache.doris.nereids.trees.plans.Plan; | ||
|
||
import java.util.List; | ||
|
||
/** UnboundPlan */ | ||
public interface UnboundPlan extends Plan { | ||
@Override | ||
default LogicalProperties computeLogicalProperties() { | ||
return UnboundLogicalProperties.INSTANCE; | ||
} | ||
|
||
@Override | ||
default List<Slot> computeOutput() { | ||
throw new UnboundException("output"); | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.