<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="performance-schema-queries">
      </a>
      29.5 Performance Schema Queries
     </h2>
    </div>
   </div>
  </div>
  <p>
   Pre-filtering limits which event information is collected and is
      independent of any particular user. By contrast, post-filtering is
      performed by individual users through the use of queries with
      appropriate
   <code class="literal">
    WHERE
   </code>
   clauses that restrict what
      event information to select from the events available after
      pre-filtering has been applied.
  </p>
  <p>
   In
   <a class="xref" href="performance-schema-pre-filtering.html" title="29.4.3 Event Pre-Filtering">
    Section 29.4.3, “Event Pre-Filtering”
   </a>
   , an example
      showed how to pre-filter for file instruments. If the event tables
      contain both file and nonfile information, post-filtering is
      another way to see information only for file events. Add a
   <code class="literal">
    WHERE
   </code>
   clause to queries to restrict event
      selection appropriately:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa63180855"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> THREAD_ID<span class="token punctuation">,</span> NUMBER_OF_BYTES
       <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_waits_history
       <span class="token keyword">WHERE</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'wait/io/file/%'</span>
       <span class="token operator">AND</span> NUMBER_OF_BYTES <span class="token operator">IS</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> THREAD_ID <span class="token punctuation">|</span> NUMBER_OF_BYTES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>        11 <span class="token punctuation">|</span>              66 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>        11 <span class="token punctuation">|</span>              47 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>        11 <span class="token punctuation">|</span>             139 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>         5 <span class="token punctuation">|</span>              24 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>         5 <span class="token punctuation">|</span>             834 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
  </div>
  <p>
   Most Performance Schema tables have indexes, which gives the
      optimizer access to execution plans other than full table scans.
      These indexes also improve performance for related objects, such
      as
   <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
    <code class="literal">
     sys
    </code>
   </a>
   schema views that use those
      tables. For more information, see
   <a class="xref" href="performance-schema-optimization.html" title="10.2.4 Optimizing Performance Schema Queries">
    Section 10.2.4, “Optimizing Performance Schema Queries”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
