OPTCOMPIND session environment option
Use the OPTCOMPIND session environment option of the SET ENVIRONMENT statement to specify methods for the query optimizer to choose in join queries and MERGE statements of the currently executing routine.
The SET ENVIRONMENT OPTCOMPIND statement of SQL supports the following syntax:
Usage
'0'
or"0"
- The query optimizer uses a nested-loop join where possible, rather than a sort-merge join or a hash join
'1'
or"1"
- If the transaction isolation level is Repeatable Read, the optimizer
behaves as in setting
'0'
, as described above; for any other isolation level, it behaves like setting'2'
, as described next. '2'
or"2"
- The query optimizer does not necessarily prefer nested-loop joins, but bases its decision entirely on the estimated cost, regardless of the transaction isolation mode.
DEFAULT
- This keyword restores the system default value, as described in the OPTCOMPIND topic of the Informix® Guide to SQL: Reference
Any numeric setting of the SET ENVIRONMENT OPTCOMPIND statement can override the default setting of the OPTCOMPIND environment variable while the routine that issues this statement is running in the current session.
That is, the scope of this session environment setting is local to the routine that issues the SET ENVIRONMENT OPTCOMPIND statement. That setting persists only until the routine exits, or until the same routine issues another SET ENVIRONMENT OPTCOMPIND statement, rather than persisting for the entire session. After that routine terminates, the setting reverts to the system default value that the OPTCOMPIND environment variable specifies, or else the value set by another method in the order of precedence described below in this topic.
No other option to SET ENVIRONMENT has a scope that is local to the routine that sets the value. The settings of all the other SET ENVIRONMENT options persist until the session ends, or until another SQL statement in the same session resets their value.
The system default value of OPTCOMPIND
- the OPTCOMPIND environment variable setting
- OPTCOMPIND configuration parameter setting, if OPTCOMPIND is not set
2
, if neither of the above are set.
Examples of resetting OPTCOMPIND
SET ENVIRONMENT OPTCOMPIND '2';
SET ENVIRONMENT OPTCOMPIND '1';
If
isolation level is Repeatable Read, the query optimizer chooses index
scans, This is the recommended setting for Repeatable Read, because
it reduces the risk of lock contention among connections when hash-join
execution paths set temporary locks on all records of joined tables.SET ENVIRONMENT OPTCOMPIND "0";
SET ENVIRONMENT OPTCOMPIND DEFAULT;
For more information about the different join methods that the optimizer can choose, and the performance implications of the OPTCOMPIND session environment setting, see your Informix® Performance Guide.
For more information about the OPTCOMPIND configuration parameter, see your Informix® Administrator's Reference.
For more information about the OPTCOMPIND environment variable, see your Informix® Guide to SQL: Reference.