db2advis is a tool that recommends database objects based
on an existing database and a set of queries.node
SYNTAX:sql
db2advis -d <db name> [-t <time>] [-l <disk_space>]
-s "sql stmt" | -i <infile> | -w <workload name> | -g | -qp [<starttime> [<endtime>]] | -wlm <evmonname> [<workload or serviceclass>] [<starttime> [<endtime>]]
[ -[user|a] <username> [/<password>] ]
[ -[type|m] <advis_type> ]
[ -[compress|k] <compression level> ]
[ -[tbsp|b] <MQT creation table space> ]
[ -[simtbsp|c] <simulation table space> ]
[ -[schema|n] <schema name> ]
[ -[qualifier|q] <qualifying schema name>]
[ -[script|o] <output script> ]
[ -[password|x] ] [ -[sample|r] ] [ -[deferred|u] ] [ -nogen ] [ -[drop|f] ]
[ -[keep|p] ] [ -delim <char> ]
[ -mdcpctinflation <percent> ] [ -tables <table_predicate_clause> ]app
NOTE 1: only one of the following six options
can be used: [stmt,file,workload,pkg,qp,wlm]
NOTE 2: -tbsp, -simtbsp, -schema and -sample can only be specified when MQTs are to be selectedide
where:this
-[db|d] database name.
-[keep|p] keep plans in explain tables.
-[timelimit|t] maximum duration for db2advis to run, in minutes.
default is unlimited (algorithm execution continues until
no changes to the recommendations is possible).
a value of 0 means unlimited duration.
-[disklimit|l] maximum disk space in megabytes. default is
20% of total database size.
-[stmt|s] recommend database objects for this SQL statement.
-[file|i] get SQL from this input file.
-[workload|w] get SQL from rows in the ADVISE_WORKLOAD table,
specified by matching WORKLOAD_NAME.
-[pkg|g] get workload from dynamic package cache
-qp get workload from query patroller table.
Optionally, a <starttime> and <endtime> timestamp can
be added to get statements on or after the <starttime>
and optional on or before the <endtime>.
-wlm get workload from WLM activity tables for event name <evmonname>.
Optionally, a <starttime> and <endtime> timestamp can
be added to get statements on or after the <starttime>
and optional on or before the <endtime>.
Note that the optional <workload or serviceclass> is
of the form
{WORKLOADNAME|WL} <workloadname>
OR
{SERVICECLASS|SC} <superclassname>[,<subclassname>].
-[script|o] place the database objects creation script in a file.
-[user|a] username to connect with. (optional password)
-[type|m] advise type.
Subset of:
I - for index selection,
M - for MQT selection,
C - for Multi-dimensional Clustering selection,
P - for partitioning selection,
Default is I
Example: MICP - for ALL selections.
-[tbsp|b] MQT creation tbspace name (default is USERSPACE1)
-[simtbsp|c] simulation table space name that is defined only on the catalog node
-[schema|n] schema name that is used to define new MQTs
-[qualifier|q] schema name used to qualify unqualified tables
-[sample|r] gets more statistics for MQT.
-[compress|k] specifies compression OFF, LOW, MED, or HIGH. default is MED
-[drop|f] drops previously existing simulated catalog tables
-[deferred|u] specified that immediate and deferred MQTs are to be output. Default is immediate.
-[nogen] indicates that generated columns are not to be included in MDC recommendations
-[password|x] indicates that the password will be read from stdin
-delim <char> specifies <char> to be used as the statement delimiter for the
workload file input. Default delimiter is ';'
-mdcpctinflation <percent> Specifies the maximum percentage that the table
disk size can increase in an MDC recommendation.
-tables <table_predicate_clause> Indicates that only a subset of all
existing tables should be considered. The
<table_predicate_clause> must be a predicate that can
be used in the WHERE clause of a query on SYSCAT.TABLES.
this option does not apply to recommendations about new
MQTs.spa
EXAMPLE:orm
Create an input file called db2advis.in with the following 5 lines:
--#SET FREQUENCY 100
SELECT COUNT(*) FROM EMPLOYEE;
SELECT * FROM EMPLOYEE WHERE LASTNAME='HAAS';
--#SET FREQUENCY 1
SELECT AVG(BONUS), AVG(SALARY) FROM EMPLOYEE
GROUP BY WORKDEPT ORDER BY WORKDEPT;ip
run the following command and let it finish
db2advis -d sample -i db2advis.in -t 5ci
for bigger workloads, the program will take longer.get