| Modifier and Type | Field and Description |
|---|---|
| pack-priv ResultSetNode | childResult
ResultSetNode under the SingleChildResultSetNode |
| protected boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | acceptChildren(Visitor
the visitor v)Overrides org. Accept the visitor for all visitable children of this node. |
| pack-priv ResultSetNode | Returns: ResultSetNode The new top of the tree.The predicate to add predicate)Overrides org. Add a new predicate to the list. |
| pack-priv void | adjustForSortElimination()
Overrides org. Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort. |
| pack-priv void | adjustForSortElimination(RequiredRowOrdering rowOrdering)
Overrides org. Same goal as adjustForSortElimination above, but this version takes a RequiredRowOrdering to allow nodes to adjust based on the ORDER BY clause, if needed. |
| pack-priv ResultSetNode | changeAccessPath()
Overrides org. The optimizer's decision on the access path for a result set may require the generation of extra result sets. |
| pack-priv void | decrementLevel(int
The amount to decrement by. decrement)Overrides org. Decrement (query block) level (0-based) for this FromTable. |
| pack-priv ResultSetNode | Returns: ResultSetNode A RSN tree with a node which has a PredicateList on top.The number of tables in the query. numTables)Overrides org. Ensure that the top of the RSN tree has a PredicateList. |
| pack-priv boolean | Returns: boolean Whether or not the FromSubquery is flattenable.The outer from list fromList)Overrides org. Evaluate whether or not the subquery in a FromSubquery is flattenable. |
| public boolean | forUpdate()
Overrides org. Implements org. Return true if this is the target table of an update |
| pack-priv ResultSetNode | Returns: ResultSetNode The childResult from this node.Return the childResult from this node. |
| pack-priv CostEstimate | Returns: The final CostEstimate for this node, which is the final cost estimate for the child node.Overrides org. Get the final CostEstimate for this node. |
| pack-priv FromTable | Returns: The FromTable, if any, with the exposed name.The specified name to search for as an exposed name. name, String Schema name, if non-null. schemaName, boolean Whether or not we need an exact match on specified schema and table
names or match on table id. exactMatch)Overrides org. Determine whether or not the specified name is an exposed name in the current query block. |
| public AccessPath | getTrulyTheBestAccessPath()
Overrides org. Implements org. Get the best access path overall for this Optimizable. |
| public void | initAccessPaths(Optimizer
The optimizer being used. optimizer)Overrides org. Implements org. Init the access paths for this optimizable. |
| pack-priv boolean | Returns: Whether or not the underlying ResultSet tree is for a NOT EXISTS.Overrides org. Return whether or not the underlying ResultSet tree is for a NOT EXISTS join. |
| pack-priv boolean | Returns: Whether or not the underlying ResultSet tree will return a single row.Overrides org. Return whether or not the underlying ResultSet tree will return a single row, at most. |
| pack-priv boolean | Returns: Whether the underlying ResultSet tree is ordered on the specified column.The specified ColumnReference[] crs, boolean Whether or not the order of the CRs in the array can be permuted permuteOrdering, List<FromBaseTable> List that is to be filled with the FromBaseTable fbtHolder)Overrides org. Return whether or not the underlying ResultSet tree is ordered on the specified columns. |
| pack-priv ResultSetNode | modifyAccessPaths()
Overrides org. Modify the access paths according to the decisions the optimizer made. |
| pack-priv ResultSetNode | Returns: ResultSetNode The top of the optimized subtreeThe DataDictionary to use for optimization dataDictionary, PredicateList The PredicateList to optimize. This should
be a join predicate. predicates, double The number of outer joining rows outerRows)Overrides org. Optimize this SingleChildResultSetNode. |
| pack-priv ResultSetNode | Returns: The generated ProjectRestrictNode atop the original FromTable.Number of tables in the DML Statement numTables, GroupByList The group by list, if any gbl, FromList The from list, if any fromList)Overrides org. Put a ProjectRestrictNode on top of each FromTable in the FromList. |
| pack-priv void | printSubNodes(int
The depth of this node in the tree depth)Overrides org. Prints the sub-nodes of this object. |
| public void | pullOptPredicates(OptimizablePredicateList
The list to put the pulled predicates
in. optimizablePredicates)Overrides org. Implements org. Pull all the OptimizablePredicates from this Optimizable and put them in the given OptimizablePredicateList. |
| pack-priv void | pushExpressions(PredicateList
The PredicateList. predicateList)Overrides org. Push expressions down to the first ResultSetNode which can do expression evaluation and has the same referenced table map. |
| public boolean | Returns: true if references SESSION schema tables, else falseOverrides org. Return true if the node references SESSION schema tables (temporary or permanent) |
| pack-priv boolean | Returns: true if found, else falseTable name (String) to search for. name, boolean Whether or not name is for a base table baseTable)Overrides org. Search to see if a query references the specifed table name. |
| protected boolean | Returns: Whether or not we need to do reflection in order to do the projection.Determine whether we need to do reflection in order to do the projection. |
| pack-priv void | setChildResult(ResultSetNode
The new childResult for this node. childResult)Set the childResult for this node. |
| pack-priv void | setLevel(int
The query block level for this FromTable. level)Overrides org. Set the (query block) level (0-based) for this FromTable. |
| pack-priv boolean | Returns: boolean Whether or not a reference to the table was found.The table name. name, boolean Whether or not the name is for a base table. baseTable)Overrides org. Return whether or not this ResultSetNode contains a subquery with a reference to the specified target. |
| public void | updateBestPlanMap(short
Indicates whether we're adding, loading, or removing
a best plan for the OptimizerImpl/Optimizable. action, Object Object to use as the map key when adding/looking up
a plan. If it is an instance of OptimizerImpl then it corresponds
to an outer query; otherwise it's some Optimizable above this
Optimizable that could potentially reject plans chosen by the
OptimizerImpl to which this Optimizable belongs. planKey)Overrides org. Implements org. When remembering "truly the best" access path for an Optimizable, we have to keep track of which OptimizerImpl the "truly the best" access is for. |
| pack-priv int | Returns: The lock modeOverrides org. Get the lock mode for the target of an update statement (a delete or update). |
| childResult | back to summary |
|---|---|
| pack-priv ResultSetNode childResult ResultSetNode under the SingleChildResultSetNode | |
| hasTrulyTheBestAccessPath | back to summary |
|---|---|
| protected boolean hasTrulyTheBestAccessPath | |
| SingleChildResultSetNode | back to summary |
|---|---|
| pack-priv SingleChildResultSetNode(ResultSetNode childResult, Properties tableProperties, ContextManager cm) | |
| acceptChildren | back to summary |
|---|---|
| pack-priv void acceptChildren(Visitor v) throws StandardException Overrides org. Accept the visitor for all visitable children of this node.
| |
| addNewPredicate | back to summary |
|---|---|
| pack-priv ResultSetNode addNewPredicate(Predicate predicate) throws StandardException Overrides org. Add a new predicate to the list. This is useful when doing subquery transformations, when we build a new predicate with the left side of the subquery operator and the subquery's result column.
| |
| adjustForSortElimination | back to summary |
|---|---|
| pack-priv void adjustForSortElimination() Overrides org. Doc from org. Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort. Sort elimination can happen as part of preprocessing (see esp. SelectNode.preprocess(...)) or it can happen if the optimizer chooses an access path that inherently returns the rows in the correct order (also known as a "sort avoidance" plan). In either case we drop the sort and rely on the underlying result set tree to return its rows in the correct order. For most types of ResultSetNodes we automatically get the rows in the correct order if the sort was eliminated. One exception to this rule, though, is the case of an IndexRowToBaseRowNode, for which we have to disable bulk fetching on the underlying base table. Otherwise the index scan could return rows out of order if the base table is updated while the scan is "in progress" (i.e. while the result set is open). In order to account for this (and potentially other, similar issues in the future) this method exists to notify the result set node that it is expected to return rows in the correct order. The result set can then take necessary action to satsify this requirement--such as disabling bulk fetch in the case of IndexRowToBaseRowNode. All of that said, any ResultSetNodes for which we could potentially eliminate sorts should override this method accordingly. So we don't ever expect to get here.
| |
| adjustForSortElimination | back to summary |
|---|---|
| pack-priv void adjustForSortElimination(RequiredRowOrdering rowOrdering) throws StandardException Overrides org. Doc from org. Same goal as adjustForSortElimination above, but this version takes a RequiredRowOrdering to allow nodes to adjust based on the ORDER BY clause, if needed.
| |
| changeAccessPath | back to summary |
|---|---|
| pack-priv ResultSetNode changeAccessPath() throws StandardException Overrides org. Doc from org. The optimizer's decision on the access path for a result set may require the generation of extra result sets. For example, if it chooses an index for a FromBaseTable, we need an IndexToBaseRowNode above the FromBaseTable (and the FromBaseTable has to change its column list to match the index. This method in the parent class does not generate any extra result sets. It may be overridden in child classes.
| |
| decrementLevel | back to summary |
|---|---|
| pack-priv void decrementLevel(int decrement) Overrides org. Decrement (query block) level (0-based) for this FromTable. This is useful when flattening a subquery.
| |
| ensurePredicateList | back to summary |
|---|---|
| pack-priv ResultSetNode ensurePredicateList(int numTables) throws StandardException Overrides org. Ensure that the top of the RSN tree has a PredicateList.
| |
| flattenableInFromSubquery | back to summary |
|---|---|
| pack-priv boolean flattenableInFromSubquery(FromList fromList) Overrides org. Evaluate whether or not the subquery in a FromSubquery is flattenable. Currently, a FSqry is flattenable if all of the following are true: o Subquery is a SelectNode. o It contains no top level subqueries. (RESOLVE - we can relax this) o It does not contain a group by or having clause o It does not contain aggregates. | |
| forUpdate | back to summary |
|---|---|
| public boolean forUpdate() Overrides org. Implements org. Doc from org. Return true if this is the target table of an update
| |
| getChildResult | back to summary |
|---|---|
| pack-priv ResultSetNode getChildResult() Return the childResult from this node.
| |
| getFinalCostEstimate | back to summary |
|---|---|
| pack-priv CostEstimate getFinalCostEstimate() throws StandardException Overrides org. Get the final CostEstimate for this node.
| |
| getFromTableByName | back to summary |
|---|---|
| pack-priv FromTable getFromTableByName(String name, String schemaName, boolean exactMatch) throws StandardException Overrides org. Determine whether or not the specified name is an exposed name in the current query block.
| |
| getTrulyTheBestAccessPath | back to summary |
|---|---|
| public AccessPath getTrulyTheBestAccessPath() Overrides org. Implements org. Doc from org. Get the best access path overall for this Optimizable.
| |
| initAccessPaths | back to summary |
|---|---|
| public void initAccessPaths(Optimizer optimizer) Overrides org. Implements org. Doc from org. Init the access paths for this optimizable.
| |
| isNotExists | back to summary |
|---|---|
| pack-priv boolean isNotExists() Overrides org. Return whether or not the underlying ResultSet tree is for a NOT EXISTS join.
| |
| isOneRowResultSet | back to summary |
|---|---|
| pack-priv boolean isOneRowResultSet() throws StandardException Overrides org. Return whether or not the underlying ResultSet tree will return a single row, at most. This is important for join nodes where we can save the extra next on the right side if we know that it will return at most 1 row.
| |
| isOrderedOn | back to summary |
|---|---|
| pack-priv boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, List<FromBaseTable> fbtHolder) throws StandardException Overrides org. Return whether or not the underlying ResultSet tree is ordered on the specified columns. RESOLVE - This method currently only considers the outermost table of the query block.
| |
| modifyAccessPaths | back to summary |
|---|---|
| pack-priv ResultSetNode modifyAccessPaths() throws StandardException Overrides org. Doc from org. Modify the access paths according to the decisions the optimizer made. This can include adding project/restrict nodes, index-to-base-row nodes, etc.
| |
| optimize | back to summary |
|---|---|
| pack-priv ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) throws StandardException Overrides org. Optimize this SingleChildResultSetNode.
| |
| preprocess | back to summary |
|---|---|
| pack-priv ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException Overrides org. Put a ProjectRestrictNode on top of each FromTable in the FromList. ColumnReferences must continue to point to the same ResultColumn, so that ResultColumn must percolate up to the new PRN. However, that ResultColumn will point to a new expression, a VirtualColumnNode, which points to the FromTable and the ResultColumn that is the source for the ColumnReference. (The new PRN will have the original of the ResultColumnList and the ResultColumns from that list. The FromTable will get shallow copies of the ResultColumnList and its ResultColumns. ResultColumn.expression will remain at the FromTable, with the PRN getting a new VirtualColumnNode for each ResultColumn.expression.) We then project out the non-referenced columns. If there are no referenced columns, then the PRN's ResultColumnList will consist of a single ResultColumn whose expression is 1.
| |
| printSubNodes | back to summary |
|---|---|
| pack-priv void printSubNodes(int depth) Overrides org. Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.
| |
| pullOptPredicates | back to summary |
|---|---|
| public void pullOptPredicates(OptimizablePredicateList optimizablePredicates) throws StandardException Overrides org. Implements org. Doc from org. Pull all the OptimizablePredicates from this Optimizable and put them in the given OptimizablePredicateList.
| |
| pushExpressions | back to summary |
|---|---|
| pack-priv void pushExpressions(PredicateList predicateList) throws StandardException Overrides org. Push expressions down to the first ResultSetNode which can do expression evaluation and has the same referenced table map. RESOLVE - This means only pushing down single table expressions to DistinctNodes today. Once we have a better understanding of how the optimizer will work, we can push down join clauses.
| |
| referencesSessionSchema | back to summary |
|---|---|
| public boolean referencesSessionSchema() throws StandardException Overrides org. Return true if the node references SESSION schema tables (temporary or permanent)
| |
| referencesTarget | back to summary |
|---|---|
| pack-priv boolean referencesTarget(String name, boolean baseTable) throws StandardException Overrides org. Search to see if a query references the specifed table name.
| |
| reflectionNeededForProjection | back to summary |
|---|---|
| protected boolean reflectionNeededForProjection() Determine whether we need to do reflection in order to do the projection. Reflection is only needed if there is at least 1 column which is not simply selecting the source column.
| |
| setChildResult | back to summary |
|---|---|
| pack-priv void setChildResult(ResultSetNode childResult) Set the childResult for this node.
| |
| setLevel | back to summary |
|---|---|
| pack-priv void setLevel(int level) Overrides org. Set the (query block) level (0-based) for this FromTable.
| |
| subqueryReferencesTarget | back to summary |
|---|---|
| pack-priv boolean subqueryReferencesTarget(String name, boolean baseTable) throws StandardException Overrides org. Return whether or not this ResultSetNode contains a subquery with a reference to the specified target.
| |
| updateBestPlanMap | back to summary |
|---|---|
| public void updateBestPlanMap(short action, Object planKey) throws StandardException Overrides org. Implements org. Doc from org. When remembering "truly the best" access path for an Optimizable, we have to keep track of which OptimizerImpl the "truly the best" access is for. In most queries there will only be one OptimizerImpl in question, but in cases where there are nested subqueries, there will be one OptimizerImpl for every level of nesting, and each OptimizerImpl might have its own idea of what this Optimizable's "truly the best path" access path really is. In addition, there could be Optimizables above this Optimizable that might need to override the best path chosen during optimization. So whenever we save a "truly the best" path, we take note of which Optimizer/Optimizable told us to do so. Then as each level of subquery finishes optimization, the corresponding OptimizerImpl/Optimizable can load its preferred access path into this Optimizable's trulyTheBestAccessPath field and pass it up the tree, until eventually the outer-most OptimizerImpl can choose to either use the best path that it received from below (by calling "rememberAsBest()") or else use the path that it found to be "best" for itself. This method is what allows us to keep track of which OptimizerImpl or Optimizable saved which "best plan", and allows us to load the appropriate plans after each round of optimization.
| |
| updateTargetLockMode | back to summary |
|---|---|
| pack-priv int updateTargetLockMode() Overrides org. Get the lock mode for the target of an update statement (a delete or update). The update mode will always be row for CurrentOfNodes. It will be table if there is no where clause.
| |