Search in sources :

Example 31 with PlanNode

use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.

the class FilterPusher method mergeJoinOnFilter.

/**
 * merge inner joi's otheron to where if we can
 *
 * @param qtn
 * @return
 */
private static void mergeJoinOnFilter(PlanNode qtn) {
    if (PlanUtil.isGlobalOrER(qtn))
        return;
    if (qtn.type().equals(PlanNodeType.JOIN) && ((JoinNode) qtn).isInnerJoin()) {
        JoinNode jn = (JoinNode) qtn;
        Item otherJoinOn = jn.getOtherJoinOnFilter();
        jn.setOtherJoinOnFilter(null);
        jn.query(FilterUtils.and(otherJoinOn, jn.getWhereFilter()));
    }
    for (PlanNode child : qtn.getChildren()) {
        mergeJoinOnFilter(child);
    }
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) PlanNode(com.actiontech.dble.plan.node.PlanNode) JoinNode(com.actiontech.dble.plan.node.JoinNode)

Example 32 with PlanNode

use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.

the class FilterPusher method getMergeNode.

private static PlanNode getMergeNode(PlanNode qtn, List<Item> dnfNodeToPush) {
    // union's where can be pushed down ,but it must be replace to child's condition
    Item node = FilterUtils.and(dnfNodeToPush);
    if (node != null) {
        qtn.query(FilterUtils.and(qtn.getWhereFilter(), node));
    }
    Item mergeWhere = qtn.getWhereFilter();
    // push down merge's condition
    qtn.query(null);
    List<Item> pushFilters = PlanUtil.getPushItemsToUnionChild((MergeNode) qtn, mergeWhere, ((MergeNode) qtn).getColIndexs());
    List<PlanNode> childs = qtn.getChildren();
    for (int index = 0; index < childs.size(); index++) {
        PlanNode child = childs.get(index);
        if (pushFilters != null) {
            Item pushFilter = pushFilters.get(index);
            child.query(FilterUtils.and(child.getWhereFilter(), pushFilter));
        }
        FilterPusher.optimize(child);
    }
    return qtn;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) PlanNode(com.actiontech.dble.plan.node.PlanNode)

Example 33 with PlanNode

use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.

the class GlobalTableProcessor method calcUnGlobalCount.

private static int calcUnGlobalCount(PlanNode tn) {
    int unGlobalCount = 0;
    for (ItemSubQuery subQuery : tn.getSubQueries()) {
        PlanNode subNode = subQuery.getPlanNode();
        resetNoShardNode(tn, subNode);
        unGlobalCount += subNode.getUnGlobalTableCount();
    }
    for (PlanNode tnChild : tn.getChildren()) {
        if (tnChild != null) {
            resetNoShardNode(tn, tnChild);
            unGlobalCount += tnChild.getUnGlobalTableCount();
        }
    }
    return unGlobalCount;
}
Also used : PlanNode(com.actiontech.dble.plan.node.PlanNode) ItemSubQuery(com.actiontech.dble.plan.common.item.subquery.ItemSubQuery)

Example 34 with PlanNode

use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.

the class JoinERProcessor method optimize.

public static PlanNode optimize(PlanNode qtn) {
    if (qtn instanceof JoinNode) {
        qtn = new ERJoinChooser((JoinNode) qtn).optimize();
    } else {
        for (int i = 0; i < qtn.getChildren().size(); i++) {
            PlanNode sub = qtn.getChildren().get(i);
            qtn.getChildren().set(i, optimize(sub));
        }
    }
    return qtn;
}
Also used : PlanNode(com.actiontech.dble.plan.node.PlanNode) JoinNode(com.actiontech.dble.plan.node.JoinNode)

Example 35 with PlanNode

use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.

the class JoinStrategyProcessor method optimize.

public static PlanNode optimize(PlanNode qtn) {
    if (PlanUtil.isGlobalOrER(qtn))
        return qtn;
    if (qtn.type() == PlanNode.PlanNodeType.JOIN) {
        JoinNode jn = (JoinNode) qtn;
        if (jn.getLeftNode().type() == PlanNode.PlanNodeType.TABLE && jn.getRightNode().type() == PlanNode.PlanNodeType.TABLE) {
            JoinStrategyChooser chooser = new JoinStrategyChooser((JoinNode) qtn);
            chooser.tryNestLoop();
            return qtn;
        }
    }
    for (PlanNode child : qtn.getChildren()) optimize(child);
    return qtn;
}
Also used : PlanNode(com.actiontech.dble.plan.node.PlanNode) JoinNode(com.actiontech.dble.plan.node.JoinNode)

Aggregations

PlanNode (com.actiontech.dble.plan.node.PlanNode)50 JoinNode (com.actiontech.dble.plan.node.JoinNode)16 Item (com.actiontech.dble.plan.common.item.Item)14 ArrayList (java.util.ArrayList)10 QueryNode (com.actiontech.dble.plan.node.QueryNode)8 ItemFuncEqual (com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual)6 MySQLOutPutException (com.actiontech.dble.plan.common.exception.MySQLOutPutException)5 MySQLPlanNodeVisitor (com.actiontech.dble.plan.visitor.MySQLPlanNodeVisitor)5 ItemSubQuery (com.actiontech.dble.plan.common.item.subquery.ItemSubQuery)4 SQLSelectStatement (com.alibaba.druid.sql.ast.statement.SQLSelectStatement)4 DMLResponseHandler (com.actiontech.dble.backend.mysql.nio.handler.query.DMLResponseHandler)3 NamedField (com.actiontech.dble.plan.NamedField)3 ErrorPacket (com.actiontech.dble.net.mysql.ErrorPacket)2 Order (com.actiontech.dble.plan.Order)2 TableNode (com.actiontech.dble.plan.node.TableNode)2 HashSet (java.util.HashSet)2 BaseHandlerBuilder (com.actiontech.dble.backend.mysql.nio.handler.builder.BaseHandlerBuilder)1 HandlerBuilder (com.actiontech.dble.backend.mysql.nio.handler.builder.HandlerBuilder)1 TempTableHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.TempTableHandler)1 CallBackHandler (com.actiontech.dble.backend.mysql.nio.handler.util.CallBackHandler)1