<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="sys-schema-prerequisites">
      </a>
      30.1 Prerequisites for Using the sys Schema
     </h2>
    </div>
   </div>
  </div>
  <p>
   Before using the
   <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
    <code class="literal">
     sys
    </code>
   </a>
   schema, the
      prerequisites described in this section must be satisfied.
  </p>
  <p>
   Because the
   <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
    <code class="literal">
     sys
    </code>
   </a>
   schema provides an
      alternative means of accessing the Performance Schema, the
      Performance Schema must be enabled for the
   <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
    <code class="literal">
     sys
    </code>
   </a>
   schema to work. See
   <a class="xref" href="performance-schema-startup-configuration.html" title="29.3 Performance Schema Startup Configuration">
    Section 29.3, “Performance Schema Startup Configuration”
   </a>
   .
  </p>
  <p>
   For full access to the
   <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
    <code class="literal">
     sys
    </code>
   </a>
   schema, a
      user must have these privileges:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="privileges-provided.html#priv_select">
       <code class="literal">
        SELECT
       </code>
      </a>
      on all
      <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
       <code class="literal">
        sys
       </code>
      </a>
      tables and views
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="privileges-provided.html#priv_execute">
       <code class="literal">
        EXECUTE
       </code>
      </a>
      on all
      <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
       <code class="literal">
        sys
       </code>
      </a>
      stored procedures and
          functions
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="privileges-provided.html#priv_insert">
       <code class="literal">
        INSERT
       </code>
      </a>
      and
      <a class="link" href="privileges-provided.html#priv_update">
       <code class="literal">
        UPDATE
       </code>
      </a>
      for the
      <a class="link" href="sys-sys-config.html" title="30.4.2.1 The sys_config Table">
       <code class="literal">
        sys_config
       </code>
      </a>
      table, if changes are
          to be made to it
     </p>
    </li>
    <li class="listitem">
     <p>
      Additional privileges for certain
      <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
       <code class="literal">
        sys
       </code>
      </a>
      schema stored procedures and
          functions, as noted in their descriptions (for example, the
      <a class="link" href="sys-ps-setup-save.html" title="30.4.4.14 The ps_setup_save() Procedure">
       <code class="literal">
        ps_setup_save()
       </code>
      </a>
      procedure)
     </p>
    </li>
   </ul>
  </div>
  <p>
   It is also necessary to have privileges for the objects underlying
      the
   <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
    <code class="literal">
     sys
    </code>
   </a>
   schema objects:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="privileges-provided.html#priv_select">
       <code class="literal">
        SELECT
       </code>
      </a>
      on any Performance
          Schema tables accessed by
      <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
       <code class="literal">
        sys
       </code>
      </a>
      schema objects, and
      <a class="link" href="privileges-provided.html#priv_update">
       <code class="literal">
        UPDATE
       </code>
      </a>
      for
          any tables to be updated using
      <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
       <code class="literal">
        sys
       </code>
      </a>
      schema objects
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="privileges-provided.html#priv_process">
       <code class="literal">
        PROCESS
       </code>
      </a>
      for the
      <code class="literal">
       INFORMATION_SCHEMA
      </code>
      <a class="link" href="information-schema-innodb-buffer-page-table.html" title="28.4.2 The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table">
       <code class="literal">
        INNODB_BUFFER_PAGE
       </code>
      </a>
      table
     </p>
    </li>
   </ul>
  </div>
  <p>
   Certain Performance Schema instruments and consumers must be
      enabled and (for instruments) timed to take full advantage of
   <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
    <code class="literal">
     sys
    </code>
   </a>
   schema capabilities:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      All
      <code class="literal">
       wait
      </code>
      instruments
     </p>
    </li>
    <li class="listitem">
     <p>
      All
      <code class="literal">
       stage
      </code>
      instruments
     </p>
    </li>
    <li class="listitem">
     <p>
      All
      <code class="literal">
       statement
      </code>
      instruments
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       <em class="replaceable">
        <code>
         xxx
        </code>
       </em>
       _current
      </code>
      and
      <code class="literal">
       <em class="replaceable">
        <code>
         xxx
        </code>
       </em>
       _history_long
      </code>
      consumers for all events
     </p>
    </li>
   </ul>
  </div>
  <p>
   You can use the
   <a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
    <code class="literal">
     sys
    </code>
   </a>
   schema itself to
      enable all of the additional instruments and consumers:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa93923863"><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 keyword">CALL</span> sys<span class="token punctuation">.</span>ps_setup_enable_instrument<span class="token punctuation">(</span><span class="token string">'wait'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CALL</span> sys<span class="token punctuation">.</span>ps_setup_enable_instrument<span class="token punctuation">(</span><span class="token string">'stage'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CALL</span> sys<span class="token punctuation">.</span>ps_setup_enable_instrument<span class="token punctuation">(</span><span class="token string">'statement'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CALL</span> sys<span class="token punctuation">.</span>ps_setup_enable_consumer<span class="token punctuation">(</span><span class="token string">'current'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CALL</span> sys<span class="token punctuation">.</span>ps_setup_enable_consumer<span class="token punctuation">(</span><span class="token string">'history_long'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    For many uses of the
    <code class="literal">
     sys
    </code>
    schema, the default
        Performance Schema is sufficient for data collection. Enabling
        all the instruments and consumers just mentioned has a
        performance impact, so it is preferable to enable only the
        additional configuration you need. Also, remember that if you
        enable additional configuration, you can easily restore the
        default configuration like this:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa84602336"><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 keyword">CALL</span> sys<span class="token punctuation">.</span>ps_setup_reset_to_default<span class="token punctuation">(</span><span class="token boolean">TRUE</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
   </div>
  </div>
 </div>
 <br/>
</div>
