Search in sources :

Example 51 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestIndexSelection method testFixedPlanWithExpressionIndexAndAlias.

public void testFixedPlanWithExpressionIndexAndAlias() {
    AbstractPlanNode pn;
    IndexScanPlanNode ispn;
    String leftIndexName;
    pn = compile("select * from l aliased where b = ? and DECODE(a, null, 0, a) = 0 and id = ?;");
    // System.out.println("DEBUG: " + pn.toExplainPlanString());
    pn = pn.getChild(0);
    assertTrue(pn instanceof IndexScanPlanNode);
    ispn = (IndexScanPlanNode) pn;
    assertEquals("DECODE_IDX3", ispn.getTargetIndexName());
    assertEquals(3, ispn.getSearchKeyExpressions().size());
    pn = compile("select * from l aliased, l where l.b = ? and DECODE(l.a, null, 0, l.a) = 0 and l.id = ? and l.lname = aliased.lname;");
    //* to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
    checkDualIndexedJoin(pn, "IDX_A", "DECODE_IDX3", 3);
    pn = compile("select * from l x, l where x.b = ? and DECODE(x.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
    //* to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
    // Skip the Send, Projection, and NestLoop plan nodes.
    pn = pn.getChild(0).getChild(0).getChild(0);
    assertTrue(pn instanceof IndexScanPlanNode);
    ispn = (IndexScanPlanNode) pn;
    assertEquals("DECODE_IDX3", ispn.getTargetIndexName());
    assertEquals(3, ispn.getSearchKeyExpressions().size());
    pn = compile("select * from l x, l where x.b = ? and DECODE(x.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
    //*enable to debug*/System.out.println("DEBUG: " + pn.toExplainPlanString());
    // Skip the Send, Projection, and NestLoop plan nodes.
    pn = pn.getChild(0).getChild(0).getChild(0);
    assertTrue(pn instanceof IndexScanPlanNode);
    ispn = (IndexScanPlanNode) pn;
    assertEquals("DECODE_IDX3", ispn.getTargetIndexName());
    assertEquals(3, ispn.getSearchKeyExpressions().size());
    pn = compile("select * from l x, l where l.b = ? and DECODE(x.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
    //*enable to debug*/System.out.println("DEBUG: " + pn.toExplainPlanString());
    leftIndexName = HSQLInterface.AUTO_GEN_NAMED_CONSTRAINT_IDX + "PK_LOG";
    checkDualIndexedJoin(pn, leftIndexName, "DECODE_IDX3", 1);
    pn = compile("select * from l x, l where l.b = ? and DECODE(x.a, null, 0, x.a) = 0 and l.id = ? and l.lname = x.lname;");
    //*enable to debug*/System.out.println("DEBUG: " + pn.toExplainPlanString());
    checkDualIndexedJoin(pn, "IDX_A", "DECODE_IDX3", 1);
    pn = compile("select * from l x, l where x.b = ? and DECODE(l.a, null, 0, l.a) = 0 and x.id = ? and l.lname = x.lname;");
    //*enable to debug*/System.out.println("DEBUG: " + pn.toExplainPlanString());
    checkDualIndexedJoin(pn, "IDX_A", "DECODE_IDX3", 1);
    pn = compile("select * from l x, l where l.b = ? and DECODE(x.a, null, 0, x.a) = 0 and l.id = ? and l.lname = x.lname;");
    //*enable to debug*/System.out.println("DEBUG: " + pn.toExplainPlanString());
    checkDualIndexedJoin(pn, "IDX_A", "DECODE_IDX3", 1);
    pn = compile("select * from l x, l where x.b = ? and DECODE(l.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
    //*enable to debug*/System.out.println("DEBUG: " + pn.toExplainPlanString());
    checkDualIndexedJoin(pn, "IDX_A", "DECODE_IDX3", 1);
    pn = compile("select * from l x, l where l.b = ? and DECODE(x.a, null, 0, l.a) = 0 and l.id = ? and l.lname = x.lname;");
    //*enable to debug*/System.out.println("DEBUG: " + pn.toExplainPlanString());
    checkDualIndexedJoin(pn, "IDX_A", "DECODE_IDX3", 1);
    pn = compile("select * from l x, l where x.b = ? and DECODE(l.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
    //*enable to debug*/System.out.println("DEBUG: " + pn.toExplainPlanString());
    checkDualIndexedJoin(pn, "IDX_A", "DECODE_IDX3", 1);
    pn = compile("select * from l x, l where l.b = ? and DECODE(x.a, null, 0, l.a) = 0 and x.id = ? and l.lname = x.lname;");
    //*enable to debug*/System.out.println("DEBUG: " + pn.toExplainPlanString());
    leftIndexName = HSQLInterface.AUTO_GEN_NAMED_CONSTRAINT_IDX + "PK_LOG";
    checkDualIndexedJoin(pn, leftIndexName, "DECODE_IDX3", 1);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode)

Example 52 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestIndexCoveringPlans method testCover3ColumnsInOrderWithLessThan.

public void testCover3ColumnsInOrderWithLessThan() {
    AbstractPlanNode pn = compile("select a from t where a = ? and c = ? and b < ?;");
    pn = pn.getChild(0);
    if (pn != null) {
        System.out.println(pn.toJSONString());
    }
    assertTrue(pn instanceof IndexScanPlanNode);
    IndexScanPlanNode ispn = (IndexScanPlanNode) pn;
    assertEquals("COVER3_TREE", ispn.getTargetIndexName());
    assertEquals(IndexLookupType.LT, ispn.getLookupType());
    assertEquals(3, ispn.getSearchKeyExpressions().size());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode)

Example 53 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestIndexCoveringPlans method testSingleColumnLessThan.

public void testSingleColumnLessThan() {
    AbstractPlanNode pn = compile("select a from t where a < ?;");
    pn = pn.getChild(0);
    if (pn != null) {
        System.out.println(pn.toJSONString());
    }
    assertTrue(pn instanceof IndexScanPlanNode);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode)

Example 54 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestIndexCoveringPlans method testEng1023.

// The planner should choose cover2_tree, which is over columns a and b.
// It should use this index as a covering index, so it should be a
// greater-than lookup type
public void testEng1023() {
    AbstractPlanNode pn = compile("select a from t where a = ? and b < ?;");
    pn = pn.getChild(0);
    if (pn != null) {
        System.out.println(pn.toJSONString());
    }
    assertTrue(pn instanceof IndexScanPlanNode);
    IndexScanPlanNode ispn = (IndexScanPlanNode) pn;
    assertEquals("COVER2_TREE", ispn.getTargetIndexName());
    assertEquals(IndexLookupType.LT, ispn.getLookupType());
    assertEquals(2, ispn.getSearchKeyExpressions().size());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode)

Example 55 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestIndexCoveringPlans method testCover3ColumnsOutOfOrderWithLessThan.

public void testCover3ColumnsOutOfOrderWithLessThan() {
    AbstractPlanNode pn = compile("select a from t where a = ? and b = ? and c < ?;");
    pn = pn.getChild(0);
    if (pn != null) {
        System.out.println(pn.toJSONString());
    }
    assertTrue(pn instanceof IndexScanPlanNode);
    IndexScanPlanNode ispn = (IndexScanPlanNode) pn;
    assertEquals("IDX_1_TREE", ispn.getTargetIndexName());
    assertEquals(IndexLookupType.LT, ispn.getLookupType());
    assertEquals(3, ispn.getSearchKeyExpressions().size());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode)

Aggregations

AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)259 AbstractExpression (org.voltdb.expressions.AbstractExpression)55 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)48 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)48 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)46 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)44 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)37 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)37 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)29 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)29 ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)27 SendPlanNode (org.voltdb.plannodes.SendPlanNode)27 MergeReceivePlanNode (org.voltdb.plannodes.MergeReceivePlanNode)20 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)16 NestLoopIndexPlanNode (org.voltdb.plannodes.NestLoopIndexPlanNode)16 SchemaColumn (org.voltdb.plannodes.SchemaColumn)15 NodeSchema (org.voltdb.plannodes.NodeSchema)14 UnionPlanNode (org.voltdb.plannodes.UnionPlanNode)14 LimitPlanNode (org.voltdb.plannodes.LimitPlanNode)12 PlanNodeType (org.voltdb.types.PlanNodeType)12