# PlanExporter XML format

The `PlanExporter` tool extracts the query plan of an executed query as a XML document by using the statistics captured from Derby XPLAIN style tables.

An XML document generated by the `PlanExporter` tool has the following structure.

- The basic tree structure:
  - `plan`: The root of the XML tree
    - `statement`: First child, the query executed
    - `time`: Second child, the time that this query executed
    - `stmt_id` : Third child, the STMT_ID of the query
    - `details`: Fourth child, containing the query plan
- The `statement` element:

  This element has only its value. That value implies the query executed, as retrieved from the STMT_TEXT row of the SYSXPLAIN_STATEMENTS table.

  For example:

      <statement>select * from my_table</statement>

- The `time` element:

  This element has only its value. That value implies the date and time when the query executed, as retrieved from the XPLAIN_TIME row of the SYSXPLAIN_STATEMENTS table.

  For example:

      <time>2010-07-13 14:27:59.405</time>

- The `stmt_id` element:

  This element has only its value. That value implies the statement ID of the query executed, as retrieved from the STMT_ID row of the SYSXPLAIN_STATEMENTS table.

  For example:

      <stmt_id>9ac8804c-0129-cc31-ca9a-00000047f1e8</stmt_id>

- The `details` element:

  This element contains the query plan, as a tree structure of plan nodes.

  For a particular query there is only one root plan node.

- A `node` element:

  Contains the details of a plan node of the query plan. This element can contain zero or many child elements of the same type (`node` elements).

  This element contains one or more attributes, given that they are not null. The possible attributes and their meanings are shown in the following table.

  Table 1. Attributes of the `node` element
  Attribute Name | Meaning
  --- | ---
  `name` | Name of the plan node
  `input_rows` | Retrieved from the INPUT_ROWS row of the SYSXPLAIN_RESULTSETS system table
  `returned_rows` | Retrieved from the RETURNED_ROWS row of the SYSXPLAIN_RESULTSETS system table
  `no_opens` | Retrieved from the NO_OPENS row of the SYSXPLAIN_RESULTSETS system table
  `visited_pages` | Retrieved from the NO_VISITED_PAGES row of the SYSXPLAIN_SCAN_PROPS system table
  `scan_qualifiers` | Retrieved from the SCAN_QUALIFIERS row of the SYSXPLAIN_SCAN_PROPS system table
  `next_qualifiers` | Retrieved from the NEXT_QUALIFIERS row of the SYSXPLAIN_SCAN_PROPS system table
  `scanned_object` | Retrieved from the SCAN_OBJECT_NAME row of the SYSXPLAIN_SCAN_PROPS system table
  `scan_type` | Retrieved from the SCAN_TYPE row of the SYSXPLAIN_SCAN_PROPS system table
  `sort_type` | Retrieved from the SORT_TYPE row of the SYSXPLAIN_SORT_PROPS system table
  `sorter_output` | Retrieved from the NO_OUTPUT_ROWS row of the SYSXPLAIN_SORT_PROPS system table

  For example:

      <node name="TABLESCAN" returned_rows="100000" no_opens="1"
      visited_pages="2165" scan_qualifiers="None" scanned_object="USERS"
      scan_type="HEAP">

Parent topic: PlanExporter
Related concepts
Using PlanExporter
Related reference
PlanExporter example