<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="optimizer-tracing-typical-usage">
      </a>
      10.15.1 Typical Usage
     </h3>
    </div>
   </div>
  </div>
  <p>
   To perform optimizer tracing entails the following steps:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Enable tracing by executing
      <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
       <code class="literal">
        SET
       </code>
      </a>
      <a class="link" href="server-system-variables.html#sysvar_optimizer_trace">
       <code class="literal">
        optimizer_trace="enabled=ON"
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Execute the statement to be traced. See
      <a class="xref" href="traceable-statements.html" title="10.15.3 Traceable Statements">
       Section 10.15.3, “Traceable Statements”
      </a>
      , for a listing of
          statements which can be traced.
     </p>
    </li>
    <li class="listitem">
     <p>
      Examine the contents of the
      <a class="link" href="information-schema-optimizer-trace-table.html" title="28.3.19 The INFORMATION_SCHEMA OPTIMIZER_TRACE Table">
       <code class="literal">
        INFORMATION_SCHEMA.OPTIMIZER_TRACE
       </code>
      </a>
      table.
     </p>
    </li>
    <li class="listitem">
     <p>
      To examine traces for multiple queries, repeat the previous
          two steps as needed.
     </p>
    </li>
    <li class="listitem">
     <p>
      To disable tracing after you have finished, execute
      <code class="literal">
       SET optimizer_trace="enabled=OFF"
      </code>
      .
     </p>
    </li>
   </ol>
  </div>
  <p>
   You can trace only statements which are executed within the
      current session; you cannot see traces from other sessions.
  </p>
 </div>
 <br/>
</div>
