db_plan script
The db_plan script analyzes query plans and generates a report of important details in the specified plan. The script also obtains and displays many additional pieces of information that are not in the plan file.
Syntax
The db_plan command is part of the Db2 support tools. It analyzes a query plan that you specified and exports a brief report of useful details, such as the number of Cross Product Join, Merge Join or table scan details. To run the command, either specify the directory of a valid query plan file or use -last | -max to let Db2® Warehouse scan the required query plan for you. When using -last | -max, a database name is required following -d | -db to specify the target database.
db_plan <planfile> | [-last|-max] [-d|-db <database>]
Parameters
- planfile
- Specifies a plan file name, which can be text or a number, optionally followed by a .pln extension. For example, test, test.pln, 14335, and 14335.pln are all valid.
- -last|-max
- Specifies that the script obtains the maximum plan ID from the system and analyzes the
associated plan file, which can be for an active or a completed query. You can use this parameter
instead of specifying a plan file name or number. You must use it with the -db
parameter.
Note that the -last parameter might not give you the plan that you are interested in. This parameter tends to work best if you are the only one using the system at the time.
- -db database_name
- Specifies the name of the database. This script can usually determine the database even if you
don't specify this parameter. However, it allows you to narrow down the results when using
*.pln
.
Outputs
An analysis of the plan file is produced.