<div id="docs-body">
 <div class="chapter">
  <div class="titlepage">
   <div>
    <div>
     <h1 class="title">
      <a name="performance-schema">
      </a>
      Chapter 29 MySQL Performance Schema
     </h1>
    </div>
   </div>
  </div>
  <div class="toc">
   <p>
    <b>
     Table of Contents
    </b>
   </p>
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="performance-schema-quick-start.html">
       29.1 Performance Schema Quick Start
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-build-configuration.html">
       29.2 Performance Schema Build Configuration
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-startup-configuration.html">
       29.3 Performance Schema Startup Configuration
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-runtime-configuration.html">
       29.4 Performance Schema Runtime Configuration
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="performance-schema-timing.html">
         29.4.1 Performance Schema Event Timing
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-filtering.html">
         29.4.2 Performance Schema Event Filtering
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-pre-filtering.html">
         29.4.3 Event Pre-Filtering
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-instrument-filtering.html">
         29.4.4 Pre-Filtering by Instrument
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-object-filtering.html">
         29.4.5 Pre-Filtering by Object
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-thread-filtering.html">
         29.4.6 Pre-Filtering by Thread
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-consumer-filtering.html">
         29.4.7 Pre-Filtering by Consumer
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-consumer-configurations.html">
         29.4.8 Example Consumer Configurations
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-filtering-names.html">
         29.4.9 Naming Instruments or Consumers for Filtering Operations
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-instrumentation-checking.html">
         29.4.10 Determining What Is Instrumented
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="performance-schema-queries.html">
       29.5 Performance Schema Queries
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-instrument-naming.html">
       29.6 Performance Schema Instrument Naming Conventions
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-status-monitoring.html">
       29.7 Performance Schema Status Monitoring
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-atom-molecule-events.html">
       29.8 Performance Schema Atom and Molecule Events
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-event-tables.html">
       29.9 Performance Schema Tables for Current and Historical Events
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-statement-digests.html">
       29.10 Performance Schema Statement Digests and Sampling
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-table-characteristics.html">
       29.11 Performance Schema General Table Characteristics
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-table-descriptions.html">
       29.12 Performance Schema Table Descriptions
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="performance-schema-table-reference.html">
         29.12.1 Performance Schema Table Reference
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-setup-tables.html">
         29.12.2 Performance Schema Setup Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-instance-tables.html">
         29.12.3 Performance Schema Instance Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-wait-tables.html">
         29.12.4 Performance Schema Wait Event Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-stage-tables.html">
         29.12.5 Performance Schema Stage Event Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-statement-tables.html">
         29.12.6 Performance Schema Statement Event Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-transaction-tables.html">
         29.12.7 Performance Schema Transaction Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-connection-tables.html">
         29.12.8 Performance Schema Connection Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-connection-attribute-tables.html">
         29.12.9 Performance Schema Connection Attribute Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-user-variable-tables.html">
         29.12.10 Performance Schema User-Defined Variable Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-replication-tables.html">
         29.12.11 Performance Schema Replication Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-ndb-cluster-tables.html">
         29.12.12 Performance Schema NDB Cluster Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-lock-tables.html">
         29.12.13 Performance Schema Lock Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-system-variable-tables.html">
         29.12.14 Performance Schema System Variable Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-status-variable-tables.html">
         29.12.15 Performance Schema Status Variable Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-thread-pool-tables.html">
         29.12.16 Performance Schema Thread Pool Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-firewall-tables.html">
         29.12.17 Performance Schema Firewall Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-keyring-tables.html">
         29.12.18 Performance Schema Keyring Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-clone-tables.html">
         29.12.19 Performance Schema Clone Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-summary-tables.html">
         29.12.20 Performance Schema Summary Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-telemetry-tables.html">
         29.12.21 Performance Schema Telemetry Tables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-miscellaneous-tables.html">
         29.12.22 Performance Schema Miscellaneous Tables
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="performance-schema-option-variable-reference.html">
       29.13 Performance Schema Option and Variable Reference
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-options.html">
       29.14 Performance Schema Command Options
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-system-variables.html">
       29.15 Performance Schema System Variables
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-status-variables.html">
       29.16 Performance Schema Status Variables
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-memory-model.html">
       29.17 The Performance Schema Memory-Allocation Model
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-and-plugins.html">
       29.18 Performance Schema and Plugins
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-examples.html">
       29.19 Using the Performance Schema to Diagnose Problems
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="performance-schema-query-profiling.html">
         29.19.1 Query Profiling Using Performance Schema
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="performance-schema-obtaining-parent-events.html">
         29.19.2 Obtaining Parent Event Information
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="performance-schema-restrictions.html">
       29.20 Restrictions on Performance Schema
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <a class="indexterm" name="idm46045075873728">
  </a>
  <a class="indexterm" name="idm46045075872688">
  </a>
  <a class="indexterm" name="idm46045075871600">
  </a>
  <a class="indexterm" name="idm46045075870112">
  </a>
  <p>
   The MySQL Performance Schema is a feature for monitoring MySQL
    Server execution at a low level. The Performance Schema has these
    characteristics:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      The Performance Schema provides a way to inspect internal
        execution of the server at runtime. It is implemented using the
      <a class="link" href="performance-schema.html" title="Chapter 29 MySQL Performance Schema">
       <code class="literal">
        PERFORMANCE_SCHEMA
       </code>
      </a>
      storage engine
        and the
      <code class="literal">
       performance_schema
      </code>
      database. The
        Performance Schema focuses primarily on performance data. This
        differs from
      <code class="literal">
       INFORMATION_SCHEMA
      </code>
      , which serves
        for inspection of metadata.
     </p>
    </li>
    <li class="listitem">
     <p>
      The Performance Schema monitors server events. An
      <span class="quote">
       “
       <span class="quote">
        event
       </span>
       ”
      </span>
      is anything the server does that takes time
        and has been instrumented so that timing information can be
        collected. In general, an event could be a function call, a wait
        for the operating system, a stage of an SQL statement execution
        such as parsing or sorting, or an entire statement or group of
        statements. Event collection provides access to information
        about synchronization calls (such as for mutexes) file and table
        I/O, table locks, and so forth for the server and for several
        storage engines.
     </p>
    </li>
    <li class="listitem">
     <p>
      Performance Schema events are distinct from events written to
        the server's binary log (which describe data modifications) and
        Event Scheduler events (which are a type of stored program).
     </p>
    </li>
    <li class="listitem">
     <p>
      Performance Schema events are specific to a given instance of
        the MySQL Server. Performance Schema tables are considered local
        to the server, and changes to them are not replicated or written
        to the binary log.
     </p>
    </li>
    <li class="listitem">
     <p>
      Current events are available, as well as event histories and
        summaries. This enables you to determine how many times
        instrumented activities were performed and how much time they
        took. Event information is available to show the activities of
        specific threads, or activity associated with particular objects
        such as a mutex or file.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <a class="link" href="performance-schema.html" title="Chapter 29 MySQL Performance Schema">
       <code class="literal">
        PERFORMANCE_SCHEMA
       </code>
      </a>
      storage
        engine collects event data using
      <span class="quote">
       “
       <span class="quote">
        instrumentation
        points
       </span>
       ”
      </span>
      in server source code.
     </p>
    </li>
    <li class="listitem">
     <p>
      Collected events are stored in tables in the
      <code class="literal">
       performance_schema
      </code>
      database. These tables can
        be queried using
      <a class="link" href="select.html" title="15.2.13 SELECT Statement">
       <code class="literal">
        SELECT
       </code>
      </a>
      statements like other tables.
     </p>
    </li>
    <li class="listitem">
     <p>
      Performance Schema configuration can be modified dynamically by
        updating tables in the
      <code class="literal">
       performance_schema
      </code>
      database through SQL statements. Configuration changes affect
        data collection immediately.
     </p>
    </li>
    <li class="listitem">
     <p>
      Tables in the Performance Schema are in-memory tables that use
        no persistent on-disk storage. The contents are repopulated
        beginning at server startup and discarded at server shutdown.
     </p>
    </li>
    <li class="listitem">
     <p>
      Monitoring is available on all platforms supported by MySQL.
     </p>
     <p>
      Some limitations might apply: The types of timers might vary per
        platform. Instruments that apply to storage engines might not be
        implemented for all storage engines. Instrumentation of each
        third-party engine is the responsibility of the engine
        maintainer. See also
      <a class="xref" href="performance-schema-restrictions.html" title="29.20 Restrictions on Performance Schema">
       Section 29.20, “Restrictions on Performance Schema”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Data collection is implemented by modifying the server source
        code to add instrumentation. There are no separate threads
        associated with the Performance Schema, unlike other features
        such as replication or the Event Scheduler.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The Performance Schema is intended to provide access to useful
    information about server execution while having minimal impact on
    server performance. The implementation follows these design goals:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Activating the Performance Schema causes no changes in server
        behavior. For example, it does not cause thread scheduling to
        change, and it does not cause query execution plans (as shown by
      <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
       <code class="literal">
        EXPLAIN
       </code>
      </a>
      ) to change.
     </p>
    </li>
    <li class="listitem">
     <p>
      Server monitoring occurs continuously and unobtrusively with
        very little overhead. Activating the Performance Schema does not
        make the server unusable.
     </p>
    </li>
    <li class="listitem">
     <p>
      The parser is unchanged. There are no new keywords or
        statements.
     </p>
    </li>
    <li class="listitem">
     <p>
      Execution of server code proceeds normally even if the
        Performance Schema fails internally.
     </p>
    </li>
    <li class="listitem">
     <p>
      When there is a choice between performing processing during
        event collection initially or during event retrieval later,
        priority is given to making collection faster. This is because
        collection is ongoing whereas retrieval is on demand and might
        never happen at all.
     </p>
    </li>
    <li class="listitem">
     <p>
      Most Performance Schema tables have indexes, which gives the
        optimizer access to execution plans other than full table scans.
        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>
    </li>
    <li class="listitem">
     <p>
      It is easy to add new instrumentation points.
     </p>
    </li>
    <li class="listitem">
     <p>
      Instrumentation is versioned. If the instrumentation
        implementation changes, previously instrumented code continues
        to work. This benefits developers of third-party plugins because
        it is not necessary to upgrade each plugin to stay synchronized
        with the latest Performance Schema changes.
     </p>
    </li>
   </ul>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    <a class="indexterm" name="idm46045075836256">
    </a>
    The MySQL
    <code class="literal">
     sys
    </code>
    schema is a set of objects that
      provides convenient access to data collected by the Performance
      Schema. The
    <code class="literal">
     sys
    </code>
    schema is installed by default.
      For usage instructions, see
    <a class="xref" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
     Chapter 30,
     <i>
      MySQL sys Schema
     </i>
    </a>
    .
   </p>
  </div>
 </div>
 <br/>
</div>
