DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Private Attributes | List of all members
Deveel.Data.Sql.Query.QueryTablePlanner.StandardJoinPlan Class Reference
Inheritance diagram for Deveel.Data.Sql.Query.QueryTablePlanner.StandardJoinPlan:
Deveel.Data.Sql.Query.QueryTablePlanner.ExpressionPlan Deveel.Data.Sql.Query.IExpressionPlan

Public Member Functions

 StandardJoinPlan (QueryTablePlanner planner, SqlBinaryExpression expression, float optimizeFactor)
 
override void AddToPlanTree ()
 
- Public Member Functions inherited from Deveel.Data.Sql.Query.QueryTablePlanner.ExpressionPlan
int CompareTo (IExpressionPlan other)
 

Private Attributes

readonly QueryTablePlanner planner
 
readonly SqlBinaryExpression expression
 

Additional Inherited Members

- Protected Member Functions inherited from Deveel.Data.Sql.Query.QueryTablePlanner.ExpressionPlan
 ExpressionPlan (float optimizeFactor)
 
- Properties inherited from Deveel.Data.Sql.Query.QueryTablePlanner.ExpressionPlan
float OptimizeFactor [get, private set]
 
- Properties inherited from Deveel.Data.Sql.Query.IExpressionPlan
float OptimizeFactor [get]
 

Detailed Description

Definition at line 1049 of file QueryTablePlanner.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Query.QueryTablePlanner.StandardJoinPlan.StandardJoinPlan ( QueryTablePlanner  planner,
SqlBinaryExpression  expression,
float  optimizeFactor 
)
inline

Definition at line 1053 of file QueryTablePlanner.cs.

1054  : base(optimizeFactor) {
1055  this.planner = planner;
1056  this.expression = expression;
1057  }

Member Function Documentation

override void Deveel.Data.Sql.Query.QueryTablePlanner.StandardJoinPlan.AddToPlanTree ( )
inlinevirtual

Implements Deveel.Data.Sql.Query.QueryTablePlanner.ExpressionPlan.

Definition at line 1059 of file QueryTablePlanner.cs.

1059  {
1060  var op = expression.ExpressionType;
1061  var lhsVar = expression.Left.AsReferenceName();
1062  var rhsVar = expression.Right.AsReferenceName();
1063  var lhsVars = expression.Left.DiscoverReferences();
1064  var rhsVars = expression.Right.DiscoverReferences();
1065 
1066  var lhsPlan = planner.JoinPlansForColumns(lhsVars);
1067  var rhsPlan = planner.JoinPlansForColumns(rhsVars);
1068 
1069  if (lhsPlan != rhsPlan) {
1070  // If either the LHS or the RHS is a single column then we can
1071  // optimize the join.
1072 
1073  if (lhsVar != null || rhsVar != null) {
1074  // If right column is a single and left column is not then we must
1075  // reverse the expression.
1076  JoinNode joinNode;
1077  if (lhsVar == null) {
1078  // Reverse the expressions and the operator
1079  joinNode = new JoinNode(rhsPlan.Plan, lhsPlan.Plan, rhsVar, op.Reverse(), expression.Left);
1080  planner.MergePlans(rhsPlan, lhsPlan, joinNode);
1081  } else {
1082  // Otherwise, use it as it is.
1083  joinNode = new JoinNode(lhsPlan.Plan, rhsPlan.Plan, lhsVar, op, expression.Right);
1084  planner.MergePlans(lhsPlan, rhsPlan, joinNode);
1085  }
1086 
1087  // Return because we are done
1088  return;
1089  }
1090  }
1091 
1092  // If we get here either both the lhs and rhs are complex expressions
1093  // or the lhs and rhs of the variable are not different plans, or
1094  // the operator is not a conditional. Either way, we must evaluate
1095  // this via a natural join of the variables involved coupled with an
1096  // exhaustive select. These types of queries are poor performing.
1097 
1098  var columnNames = expression.DiscoverReferences();
1099  var tablePlan = planner.JoinPlansForColumns(columnNames);
1100  tablePlan.UpdatePlan(new ExhaustiveSelectNode(tablePlan.Plan, expression));
1101  }
void UpdatePlan(IQueryPlanNode queryPlan)
Definition: TablePlan.cs:131
TablePlan MergePlans(TablePlan left, TablePlan right, IQueryPlanNode mergePlan)
TablePlan JoinPlansForColumns(IEnumerable< ObjectName > columnNames)

Member Data Documentation

readonly SqlBinaryExpression Deveel.Data.Sql.Query.QueryTablePlanner.StandardJoinPlan.expression
private

Definition at line 1051 of file QueryTablePlanner.cs.

readonly QueryTablePlanner Deveel.Data.Sql.Query.QueryTablePlanner.StandardJoinPlan.planner
private

Definition at line 1050 of file QueryTablePlanner.cs.


The documentation for this class was generated from the following file: