Optimizer Plan
Like the optimizer in most other relational databases, the query optimizer stores the details on how to most efficiently perform SQL operations in a query execution plan, which can be examined and customized by application developers and administrators.
The execution plan data is stored in the TimesTen SYS.PLAN
table
and includes information about which tables are to be accessed and in what order, which tables
are to be joined, and which indexes are to be used. You can use either the
ttSqlCmdQueryPlan
built-in procedure or the ttIsql
explain
command to display the query plans for recently processed SQL
statements. Users can direct the query optimizer to enable or disable the creation of an
execution plan in the SYS.PLAN
table with the generate plan optimizer hint.
(For transaction level hints, use the GenPlan
optimizer flag in the
ttOptSetFlag
built-in procedure; for statement level hints, use the
TT_GenPlan
hint in the SQL statement.) See The TimesTen Query Optimizer in the
Oracle TimesTen In-Memory Database Operations
Guide for more information.
The execution plan designates a separate step for each database operation to be performed to run the query. The steps in the plan are organized into levels that designate which steps must be completed to generate the results required by the step or steps at the next level.
Consider this query:
SELECT COUNT(*) FROM t1, t2, t3 WHERE t3.b/t1.b > 1 AND t2.b <> 0 AND t1.a = -t2.a AND t2.a = t3.a;
In this example, the optimizer breaks down the query into its individual operations and generates a 5-step execution plan to be performed at three levels, as shown in Figure 5-4.