Before you run the PlanExporter tool, make sure that your classpath contains the Derby jar files, including derbytools.jar/
Before you run the PlanExporter tool, you must capture the stmt_id of the query you have executed from SYSXPLAIN_STATEMENTS system table. To do so, follow these steps:
Refer to "SYSCS_UTIL.SYSCS_SET_XPLAIN_SCHEMA system procedure" in the Derby Reference Manual to see how to do this.
Refer to "SYSXPLAIN_STATEMENTS system table" in the Derby Reference Manual for information about the SYSXPLAIN_STATEMENTS system table.
You can run the tool as follows in the directory where your database is located (all on one line).
java org.apache.derby.tools.PlanExporter derby_connection_URL schema_name stmt_id options
The options can be passed according to your requirements. Consider the following possible scenarios:
To generate an XML file of the query plan, specify the following option:
-xml path
The path can be either absolute or relative. If the root filename does not have a suffix, the tool appends .xml.
To generate a plain HTML file of the query plan, you can use the default simple style sheet provided with Derby. Specify the following option:
-html path
If the root filename does not have a suffix, the tool appends .html.
To generate the XML file as well, specify the following options:
-xml path -html path
To use a different style sheet that does not contain any Javascript functions, specify the following options:
-xsl path -html path
To generate the XML file as well, specify the following options:
-xml path -xsl path -html path
To generate an advanced view of the query plan, you can use advanced XSL style sheets provided with Derby inside derbytools.jar/org/apache/derby/impl/tools/planexporter/resources/, or you can specify a style sheet you created. To do this, specify the following options:
-adv -xsl fileName -xml path