DB2 10.5 for Linux, UNIX, and Windows

db2fopt - Specify query optimizer parameters command

The db2fopt command specifies parameters for use by the query optimizer. This command can be used when setting up a test system which has less physical resources than the production system.

For example, if the production system is running with sortheap=20000 and the test system can only run with sortheap=5000, you can use db2fopt on the test system to set the opt_sortheap optimizer parameter to 20000. This will direct the optimizer to use 20000 as the sort heap value when evaluating access plans while the sortheap database configuration parameter is set to 5000.

Scope
This command only affects the database partition on which it is executed.
Authorization
To query parameters using the get option: none
To update parameters, one of the following authorities is required:
  • SYSADM
  • SYSCTRL
  • SYSMAINT
Required connection
None

Command syntax

Read syntax diagramSkip visual syntax diagram
>>-db2fopt--DBname---------------------------------------------->

             .----------------------------.     
             V                            |     
>--+-update----optimizer-parameter--value-+-+------------------><
   |      .---------------------.           |   
   |      V                     |           |   
   '-get----optimizer-parameter-+-----------'   

Command parameters

DBname
Alias name of the database.
update optimizer-parameter value
Use this command to update optimizer parameters.
  • opt_buffpage
  • opt_sortheap
  • opt_locklist
  • opt_maxlocks
get optimizer-parameter
Use this command to query optimizer parameter values.
  • opt_buffpage
  • opt_sortheap
  • opt_locklist
  • opt_maxlocks

Usage notes

This tool is sometimes used in partitioned database environments that consist of heterogeneous database partition configurations. In this case, statement compilation occurs on a coordinator database partition which can have different database configuration settings from that of the database partitions in the instance on which query processing takes place.

If an optimizer parameter has a value of 0, then no optimizer value has been specified. Statement compilation will use the value from the database configuration.

Updating an optimizer parameter to a value of 0 will reset a previously updated value.

Specifying a non-numeric or a negative value on an update action will set the value to 0.

For an update to take effect, all connections must be terminated on the database partition, and the database partition must be deactivated if previously activated.

The optimizer parameters are only used for statement compilation. In partitioned database environments, they must be set on coordinator database partitions.

To determine the actual values to specify on the test system, you can obtain an explain output from the production system by using the db2exfmt tool, and review the Database context section.

Examples

Example 1
Query the values of opt_sortheap, opt_locklist, and opt_maxlocks.
db2fopt testdb get opt_sortheap opt_locklist opt_maxlocks
Example 2
Set the value for multiple parameters.
For example, the following database context section is returned from the production system.
Database Context:
----------------
        Parallelism:            None
        CPU Speed:              1.456395e-07
        Comm Speed:             0
        Buffer Pool size:       89000
        Sort Heap size:         10000
        Database Heap size:     1200
        Lock List size:         8000
        Maximum Lock List:      10
        Average Applications:   1
        Locks Available:        93030
On the test system, you can use the db2fopt command to set opt_buffpage to 89000, opt_sortheap to 10000, opt_locklist to 8000, and opt_maxlocks to 10.
db2fopt testdb update opt_buffpage 89000
                      opt_sortheap 10000
                      opt_locklist 8000 
                      opt_maxlocks 10