IBM DB2 Optimization Expert, Version 2.1

Importing a workload from an XML file

You can create an XML file to import a custom workload.

To use an XML file to specify a custom workload:
  1. Create an XML document that describes the workload.

    The specification for the XML file that defines a workload includes the following types of elements:

    workload
    The workload element is the root meaning that a valid XML file has only one workload element.
    source
    The source element is the child of workload. A workload can have more than one source element. The name attribute of the source contains a unique name for each source element. If no source element is included, the workload is considered to have a text source.
    source_detail
    The source detail element is a child of the source element.
    statement
    The statement element is the child of the source element. Each statement element represents one SQL statement in the workload. Each source element can contain more than one statement element.
    statement_text
    The statement_text element, which contains the SQL text of the statement, is a child of the statement element. A statement element cannot contain more than one statement_text element. The qualifier attribute is the specifies the qualifier of the statement. If the qualifier attribute is not specified, the qualifier attribute specified in the source_detail element is used. If that attribute is unspecified too, the current user id will be used as the statement qualifier.

    Certain symbols that are commonly part of the text of a SQL statement are invalid characters in XML. You must replace them with the corresponding enitity shown in the table below.

    Table 1. XML entity references for symbols
    Symbol to replace Entity reference to use
    < &lt;
    > &gt;
    ' &apos;
    " &quot
    & &amp;
    statement_runtime
    The statement_runtime element is a child of the statement element. A statement element cannot contain more than one statement_runtime element. A statement runtime element can include any of the following attributes with correspond to statistics for the statement:
    stat_exec
    The number of times that the statement has been executed.
    stat_cpu
    The accumulated CPU time, in seconds.
    stat_elap
    The accumulated elapsed time, in seconds.
    The following example XML statement creates a workload that contains 2 SQL statements.
    <workload desc="test workload">
    <source name="DB01 2007/11/06 - Source0">
    <source_detail condition="QUALIFIER" operator="=" value="SYSADM"/> 
    <statement>
    <statement_text qualifier="SYSIBM">SELECT * FROM SYSTABLES WHERE NAME 
     = &apos;PART&apos;
    </statement_text>
    <statement_runtime stat_exec="2" stat_cpu="0.1" stat_elap="0.2"/>
    </statement>
    <statement>
    <statement_text>SELECT
    SUM(PS_SUPPLYCOST) * AVG(P_SIZE * PS_AVAILQTY / 2) AS SupplyRatio_Expr_Operators,
    O_ORDERSTATUS || O_ORDERPRIORITY AS Key_Expr_CONCAT
    FROM PART, ORDER, PARTSUPP
    WHERE O_TOTALPRICE BETWEEN (2 * (SELECT MIN(P_RETAILPRICE) FROM PART))
                         AND (0.5 * (SELECT MAX(P_RETAILPRICE) FROM PART))
    AND O_SHIPPRIORITY IN (1, 2, 3)
    AND O_CLERK LIKE &apos;clerk&888%&apos;
    AND O_SHIPPRIORITY - 1 <= 3
    AND O_SHIPPRIORITY - 1 &gt;= 1
    AND P_PARTKEY = PS_PARTKEY
    GROUP BY PS_SUPPLYCOST, P_SIZE, PS_AVAILQTY, O_ORDERSTATUS, O_ORDERPRIORITY
    ORDER BY PS_SUPPLYCOST, P_SIZE, PS_AVAILQTY, O_ORDERSTATUS, O_ORDERPRIORITY
    </statement_text>
    <statement_runtime stat_exec="5" stat_cpu="0.2" stat_elap="0.4"/>
    </statement>
    <statement>
    <statement_text>SELECT
    XML2CLOB(XMLELEMENT(NAME &quot;LITMLINEITEM&quot;,
             XMLAGG(XMLELEMENT(NAME &quot;bo:lineItem&quot;,
             XMLNAMESPACES(&apos;urn:bo&apos; AS &quot;bo&quot;), LINEITEM.L_ORDERKEY)
             ORDER BY LINEITEM.L_ORDERKEY)) ) AS &quot;xmlLITMLINEITEM&quot;
    FROM LINEITEM
    </statement_text>
    </statement>
    </source>
    </workload>
  2. Save the XML file in a compressed folder. You must ensure that the file name of the compressed folder matches the name of the XML file.
  3. In the Project Navigator, click View Workloads. The View Workloads page opens.
  4. Click New Workload > Import. The Import Workload dialog opens.
  5. Enter the path of the zip file, or click Browse, to locate the file.


Feedback