... |
The nodes for a relational query plan are: |
* Access - Access a source. A source query is sent to the connection factory associated with the source. \[For a dependent join, this node is called Dependent Select.\] Access.\] |
|
* Dependent Procedure Access - Access a stored procedure on a source using multiple sets of input values. * Batched Update - Processes a set of updates as a batch. |
* Project - Defines the columns returned from the node. This does not alter the number of records returned. \[When there is a subquery in the Select clause, this node is called Dependent Project.\] * Project Into - Like a normal project, but outputs rows into a target table. |
* Window Function Project - Like a normal project, but includes window functions. |
* Select - Select is a criteria evaluation filter node (WHERE / HAVING). \[When there is a subquery in the criteria, this node is called Dependent Select.\] |
... |
* Sort - Defines the columns to sort on, the sort direction for each column, and whether to remove duplicates or not. |
* Dup Removal Remove - Same properties as for Sort, but the removeDups property is set to true |
|
* Grouping - Groups sets of rows into groups and evaluates aggregate functions. |
* Null - A node that produces no rows. Usually replaces a Select node where the criteria is always false (and whatever tree is underneath). There are no properties for this node. |
... |
* Limit - Returns a specified number of rows, then stops processing. Also processes an offset if present. |
* XML Table - Evaluates XMLTABLE |
|
* Text Table - Evaluates TEXTTABLE * Array Table - Evaluates ARRAYTABLE * Object Table - Evaluates OBJECTTABLE |
h2. Node Statistics |
... |
| Estimated Node Cardinality | Estimated number of records that will be output from the node; \-1 if unknown | count | |
|| Top level Statistics || Description || Units || | Data Bytes Sent | The size of the serialized data result (row and lob values) sent to the client | bytes | |
h1. Source Hints |
... |
When integrating information using a federated query planner, it is useful to be able to view the query plans that are created, to better understand how information is being accessed and processed, and to troubleshoot problems.
A query plan is a set of instructions created by a query engine for executing a command submitted by a user or application. The purpose of the query plan is to execute the user's query in as efficient a way as possible.
You can get a query plan any time you execute a command. The SQL options available are as follows:
SHOWPLAN [ON|DEBUG]- Returns the plan or the plan and the full planner debug log.
With the above options, the query plan is available from the Statement object by casting to the org.teiid.jdbc.TeiidStatement interface.
statement.execute("set showplan on"); ResultSet rs = statement.executeQuery("select ..."); TeiidStatement tstatement = statement.unwrap(TeiidStatement.class); PlanNode queryPlan = tstatement.getPlanDescription(); System.out.println(queryPlan);
The query plan is made available automatically in several of Teiid's tools.
Once a query plan has been obtained you will most commonly be looking for:
All of these issues presented above will be present subsections of the plan that are specific to relational queries. If you are executing a procedure or generating an XML document, the overall query plan will contain additional information related the surrounding procedural execution.
A query plan consists of a set of nodes organized in a tree structure. As with the above example, you will typically be interested in analyzing the textual form of the plan.
In a procedural context the ordering of child nodes implies the order of execution. In most other situation, child nodes may be executed in any order even in parallel. Only in specific optimizations, such as dependent join, will the children of a join execute serially.
Relational plans represent the actually processing plan that is composed of nodes that are the basic building blocks of logical relational operations. Physical relational plans differ from logical relational plans in that they will contain additional operations and execution specifics that were chosen by the optimizer.
The nodes for a relational query plan are:
Every node has a set of statistics that are output. These can be used to determine the amount of data flowing through the node.
Statistic | Description | Units |
---|---|---|
Node Output Rows | Number of records output from the node | count |
Node Process Time | Time processing in this node only | millisec |
Node Cumulative Process Time | Elapsed time from beginning of processing to end | millisec |
Node Cumulative Next Batch Process Time | Time processing in this node + child nodes | millisec |
Node Next Batch Calls | Number of times a node was called for processing | count |
Node Blocks | Number of times a blocked exception was thrown by this node or a child | count |
In addition to node statistics, some nodes display cost estimates computed at the node.
Cost Estimates | Description | Units |
---|---|---|
Estimated Node Cardinality | Estimated number of records that will be output from the node; -1 if unknown | count |
Top level Statistics | Description | Units |
---|---|---|
Data Bytes Sent | The size of the serialized data result (row and lob values) sent to the client | bytes |
Teiid user and transformation queries can contain a meta source hint that can provide additional information to source queries. The source hint has the form:
/*+ sh[[ KEEP ALIASES]:'arg'] source-name[ KEEP ALIASES]:'arg1' ... */
SELECT /*+ sh:'general hint' */ ... SELECT /*+ sh KEEP ALIASES:'general hint' my-oracle:'oracle hint' */ ...