db2 connect to DB_NAME
db2 "call SYSPROC.SYSINSTALLOBJECTS('EXPLAIN', 'C', CAST (NULL AS VARCHAR(128)), CAST (NULL AS VARCHAR(128)))"
This command above create a set of tables under SYSTOOLS schema this is the target default place, but you can change it. Note, the option to delete these tables is 'D' instead of 'C'.
After creating the tables you can run the command with your statement to analyze:
db2expln -database DB_NAME -schema SCHEMA_NAME -package % -statement "your query" -terminal -graph
or put your statement on a file, put the terminator ";" in the statement:
db2expln -database DB_NAME -schema SCHEMA_NAME -package % -stmtfile query.sql -terminator ";" -terminal -graph
A graph plan is displayed to visualize the access plan of the specified query.
If you want to get advise from DB2 run the command:
db2advis -d DB_NAME -q SCHEMA_NAME -s "thequery" -noxml
Nessun commento:
Posta un commento