use of org.jkiss.dbeaver.model.exec.plan.DBCPlanStyle in project dbeaver by dbeaver.
the class SQLEditor method explainQueryPlan.
private void explainQueryPlan(SQLQuery sqlQuery) {
// 1. Determine whether planner supports plan extraction
DBCQueryPlanner planner = DBUtils.getAdapter(DBCQueryPlanner.class, getDataSource());
if (planner == null) {
DBUserInterface.getInstance().showError("Execution plan", "Execution plan explain isn't supported by current datasource");
return;
}
DBCPlanStyle planStyle = planner.getPlanStyle();
if (planStyle == DBCPlanStyle.QUERY) {
explainPlanFromQuery(planner, sqlQuery);
return;
}
ExplainPlanViewer planView = null;
for (CTabItem item : resultTabs.getItems()) {
if (item.getData() instanceof ExplainPlanViewer) {
ExplainPlanViewer pv = (ExplainPlanViewer) item.getData();
if (pv.getQuery() != null && pv.getQuery().equals(sqlQuery)) {
resultTabs.setSelection(item);
planView = pv;
break;
}
}
}
if (planView == null) {
planView = new ExplainPlanViewer(this, resultTabs);
final CTabItem item = new CTabItem(resultTabs, SWT.CLOSE);
item.setControl(planView.getControl());
item.setText("Exec. Plan");
item.setToolTipText("Execution plan for\n" + sqlQuery.getText());
item.setImage(IMG_EXPLAIN_PLAN);
item.setData(planView);
UIUtils.disposeControlOnItemDispose(item);
resultTabs.setSelection(item);
}
try {
planView.explainQueryPlan(getExecutionContext(), sqlQuery);
} catch (DBCException e) {
DBUserInterface.getInstance().showError(CoreMessages.editors_sql_error_execution_plan_title, CoreMessages.editors_sql_error_execution_plan_message, e);
}
}
use of org.jkiss.dbeaver.model.exec.plan.DBCPlanStyle in project dbeaver by serge-rider.
the class SQLEditor method explainQueryPlan.
private void explainQueryPlan(SQLQuery sqlQuery) {
DBCQueryPlanner planner = GeneralUtils.adapt(getDataSource(), DBCQueryPlanner.class);
DBCPlanStyle planStyle = planner.getPlanStyle();
if (planStyle == DBCPlanStyle.QUERY) {
explainPlanFromQuery(planner, sqlQuery);
} else if (planStyle == DBCPlanStyle.OUTPUT) {
explainPlanFromQuery(planner, sqlQuery);
showOutputPanel();
} else {
ExplainPlanViewer planView = getPlanView(sqlQuery, planner);
if (planView != null) {
planView.explainQueryPlan(sqlQuery, planner);
}
}
}
Aggregations