Optimizer Hints
Optimizer hints are instructions that are passed to the TimesTen query optimizer. The optimizer considers these hints when choosing the best execution plan for your query. Most of the hints are supported both in TimesTen Scaleout and in TimesTen Classic. There are also hints that are supported only in TimesTen Scaleout. See Optimizer Hints Supported in TimesTen Scaleout Only for information.
TimesTen supports three levels of optimizer hints:
-
Statement level optimizer hints: When specified, the optimizer considers the hint for the particular statement. See Statement Level Optimizer Hints for details.
-
Transaction level optimizer hints: When specified (by calling the appropriate built-in procedure), the optimizer considers the hint for the entire transaction. See Use Optimizer Hints to Modify the Execution Plan in the Oracle TimesTen In-Memory Database Operations Guide.
-
Connection level optimizer hints: When specified, the optimizer considers the hint for the entire connection. See Use Optimizer Hints to Modify the Execution Plan in the Oracle TimesTen In-Memory Database Operations Guide and OptimizerHint in the Oracle TimesTen In-Memory Database Reference for details.
The order of precedence for optimizer hints is statement level hints, transaction level hints and then connection level hints. Table 6-2 provides a summary of the statement, transaction, and connection level optimizer hints.
Table 6-2 Summary of Statement, Transaction, and Connection Level Optimizer Hints
Statement Level Optimizer Hint | Transaction Level Optimizer Hint | Connection Level Optimizer Hint |
---|---|---|
You specify the hint within the comment syntax and after a |
You specify the hint by calling the |
You specify the hint in the |
The hint is scoped to the SQL statement. |
The hint is scoped to the transaction. |
The hint is scoped to the connection. |
The |
The |
The |
The optimizer considers the hint for the statement only. |
The optimizer considers the hint for all statements in the transaction. |
The optimizer considers the hint for all statements in the connection. |
The hint is supported in the |
The hint is not supported in the |
The hint is not supported in the |
If you specify the hint in a transaction in which transaction level optimizer hints or connection level optimizer hints are specified, the statement level optimizer hint overrides the transaction level hint or the connection level hint for the SQL statement. After TimesTen executes the SQL statement:
|
The hint is in effect for the duration of the transaction. If you specify a statement level optimizer hint in a SQL statement, the statement level optimizer hint is in effect for the statement and the optimizer does not use the transaction level hint for the statement. After TimesTen executes the statement, the original transaction level optimizer hint remains in effect for the duration of the transaction. A hint specified at this level overrides the same hint specified at the connection level. |
The hints are in effect for the duration of the connection. The order of precedence is statement level, transaction level, and then connection level. |
You use the statement level optimizer hints if you want to influence the optimizer for a specific statement. You must specify the hint for each statement in which you want to influence the optimizer. This could result in multiple alterations to your statements. |
You use the transaction level optimizer hints to influence the optimizer for all statements in a transaction. You do not have to specify a hint for each statement. The hint applies to all statements in the transaction. The hint can be overridden by specifying the hint at the statement level. |
You use the connection level optimizer hint to influence the optimizer for all statements in the connection. The hint can be overridden by specifying the hint at the transaction or at the statement level. |