Package com.foundationdb.sql.optimizer.rule

Examples of com.foundationdb.sql.optimizer.rule.ExplainPlanContext


            sessionMonitor.enterStage(MonitorStage.OPTIMIZE);
            if (transaction == null) {
                transaction = new ServerTransaction(this, true, ServerTransaction.PeriodicallyCommit.OFF);
                localTransaction = true;
            }
            ExplainPlanContext context = new ExplainPlanContext(compiler, new EmbeddedQueryContext(this));
            Explainable explainable;
            if ((sqlStmt instanceof DMLStatementNode) &&
                !(sqlStmt instanceof CallStatementNode))
                explainable = compiler.compile((DMLStatementNode)sqlStmt, parser.getParameterList(), context).getPlannable();
            else
                throw new UnsupportedSQLException("Statement not supported for EXPLAIN", sqlStmt);
            return explainable.getExplainer(context.getExplainContext());
        }
        finally {
            sessionMonitor.leaveStage();
            if (localTransaction)
                rollbackTransaction();
View Full Code Here


    @Override
    public PostgresStatement finishGenerating(PostgresServerSession server, String sql, StatementNode stmt,
                                              List<ParameterNode> params, int[] paramTypes) {
        this.schema = compiler.getSchema();
        ExplainPlanContext context = new ExplainPlanContext(compiler, new PostgresQueryContext(server, this.schema));
        ExplainStatementNode explainStmt = (ExplainStatementNode)stmt;
        StatementNode innerStmt = explainStmt.getStatement();
        if (params == null)
            params = new ParameterFinder().find(innerStmt);
        Explainable explainable;
        if (innerStmt instanceof CallStatementNode) {
            explainable = PostgresCallStatementGenerator.explainable(server, (CallStatementNode)innerStmt, params, paramTypes);
        }
        else {
            BasePlannable result = compiler.compile((DMLStatementNode)innerStmt, params, context);
            explainable = result.getPlannable();
        }
        List<String> explain;
        if (compiler instanceof PostgresJsonCompiler) {
            JsonFormatter f = new JsonFormatter();
            explain = Collections.singletonList(f.format(explainable.getExplainer(context.getExplainContext())));
        }
        else {
            DefaultFormatter.LevelOfDetail detail;
            switch (explainStmt.getDetail()) {
            case BRIEF:
                detail = DefaultFormatter.LevelOfDetail.BRIEF;
                break;
            default:
            case NORMAL:
                detail = DefaultFormatter.LevelOfDetail.NORMAL;
                break;
            case VERBOSE:
                detail = DefaultFormatter.LevelOfDetail.VERBOSE;
                break;
            }
            DefaultFormatter f = new DefaultFormatter(server.getDefaultSchemaName(), detail);
            explain = f.format(explainable.getExplainer(context.getExplainContext()));
        }
        init(explain);
        compiler = null;
        return this;
    }
View Full Code Here

    }

    @Override
    public String generateResult() throws Exception {
        StatementNode stmt = parser.parseStatement(sql);
        ExplainPlanContext context = new ExplainPlanContext(compiler, new SimpleQueryContext(null));
        BasePlannable result = compiler.compile((DMLStatementNode)stmt,
                                                parser.getParameterList(), context);
        return result.explainToString(context.getExplainContext(), OptimizerTestBase.DEFAULT_SCHEMA, DefaultFormatter.LevelOfDetail.VERBOSE_WITHOUT_COST);
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.sql.optimizer.rule.ExplainPlanContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.