DB2 Design Advisor - First thoughts...
Had a few initial struggles getting it to work:
db2advis -d sample -s "select count(*) from tpcd.orders" -m I -a db2dmin/db2admin -o advise -c SMALL -n Administrator
and it kept failing with the following error:
0 solutions were evaluated by the advisor
exiting with error code [-30082]
Well, after scratching my head quite a bit, I finally looked into db2diag.log and the error was plainly stated there - the password or username was wrong!
On fixing it, I hit the next error:
db2advis -d sample -s "select count(*) from tpcd.orders" -m MICP -o advise -c SMALL
Using user id as default schema name. Use -n option to specify schema
Explain tables not set up properly for schema ADMINISTRATOR
The insert into the ADVISE_INSTANCE table has failed.
0 solutions were evaluated by the advisor
exiting with error code [-219]
To fix that, I ran db2 -tvf EXPLAIN.DDL (this file is under sqllib\misc) and committed before db2advis started working:-)
After trying it with one or two sample queries, I also tried out the dynamic SQL cache option. I first reset the database monitor "db2 reset monitor for database
Then, I issued:
db2advis -d sample -g -m MICP -o advise -c SMALL -n TPCD
The -g tells the advisor to use the statements in the dynamic SQL cache as the workload to analyze which it duly did and came up with recommendations. Some points to note in the recommendations were:
- It was not able to use any of the queries with bind variables for the analysis (I had fired the queries from jdbc so some of them got treated as dynamic sql with parameter markers where I had prepared the statement). However, there is an option to source the workload from packages so I guess that any 'regular' static SQL will work with the design advisor - it is only prepared statements from JDBC that may have an issue as they are treated like static SQL by the app but as dynamic SQL by DB2 (since no package is created for them).
- It gives a LOT of recommendations so I guess that a DBA will still be needed even with the advisor if only to pick and choose the suggestions to implement:-)
- It even tells you which indexes are not being used and which are the ones which are present and being used well (like certifying the DBA) and of course what new ones to create.
- For MDC, it came up with some interesting options which I don't understand. For the standard TPC-H Part table, it suggested MDC on the PART_SIZE column?
- It also prints out all the DDL for the recommendations so I can be really lazy and just copy paste.
All in all, looks promising. Hoping to be able to use it on a live problem sometime!
Labels: db2advis DB2 Design Advisor Error 30082 -30082 exit 219 -219 ADVISE_INSTANCE Explain table set up
