<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="performance-schema-status-variable-tables">
      </a>
      29.12.15 Performance Schema Status Variable Tables
     </h3>
    </div>
   </div>
  </div>
  <p>
   The MySQL server maintains many status variables that provide
        information about its operation (see
   <a class="xref" href="server-status-variables.html" title="7.1.10 Server Status Variables">
    Section 7.1.10, “Server Status Variables”
   </a>
   ). Status variable
        information is available in these Performance Schema tables:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
       <code class="literal">
        global_status
       </code>
      </a>
      : Global status
            variables. An application that wants only global values
            should use this table.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
       <code class="literal">
        session_status
       </code>
      </a>
      : Status
            variables for the current session. An application that wants
            all status variable values for its own session should use
            this table. It includes the session variables for its
            session, as well as the values of global variables that have
            no session counterpart.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
       <code class="literal">
        status_by_thread
       </code>
      </a>
      : Session
            status variables for each active session. An application
            that wants to know the session variable values for specific
            sessions should use this table. It includes session
            variables only, identified by thread ID.
     </p>
    </li>
   </ul>
  </div>
  <p>
   There are also summary tables that provide status variable
        information aggregated by account, host name, and user name. See
   <a class="xref" href="performance-schema-status-variable-summary-tables.html" title="29.12.20.12 Status Variable Summary Tables">
    Section 29.12.20.12, “Status Variable Summary Tables”
   </a>
   .
  </p>
  <p>
   The session variable tables
        (
   <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
    <code class="literal">
     session_status
    </code>
   </a>
   ,
   <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
    <code class="literal">
     status_by_thread
    </code>
   </a>
   ) contain
        information only for active sessions, not terminated sessions.
  </p>
  <p>
   The Performance Schema collects statistics for global status
        variables only for threads for which the
   <code class="literal">
    INSTRUMENTED
   </code>
   value is
   <code class="literal">
    YES
   </code>
   in the
   <a class="link" href="performance-schema-threads-table.html" title="29.12.22.8 The threads Table">
    <code class="literal">
     threads
    </code>
   </a>
   table. Statistics
        for session status variables are always collected, regardless of
        the
   <code class="literal">
    INSTRUMENTED
   </code>
   value.
  </p>
  <p>
   The Performance Schema does not collect statistics for
   <code class="literal">
    Com_
    <em class="replaceable">
     <code>
      xxx
     </code>
    </em>
   </code>
   status
        variables in the status variable tables. To obtain global and
        per-session statement execution counts, use the
   <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
    <code class="literal">
     events_statements_summary_global_by_event_name
    </code>
   </a>
   and
   <a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
    <code class="literal">
     events_statements_summary_by_thread_by_event_name
    </code>
   </a>
   tables, respectively. For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa99193409"><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">SELECT</span> EVENT_NAME<span class="token punctuation">,</span> COUNT_STAR
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_statements_summary_global_by_event_name
<span class="token keyword">WHERE</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'statement/sql/%'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
    <code class="literal">
     global_status
    </code>
   </a>
   and
   <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
    <code class="literal">
     session_status
    </code>
   </a>
   tables have these
        columns:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       VARIABLE_NAME
      </code>
     </p>
     <p>
      The status variable name.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       VARIABLE_VALUE
      </code>
     </p>
     <p>
      The status variable value. For
      <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
       <code class="literal">
        global_status
       </code>
      </a>
      , this column
            contains the global value. For
      <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
       <code class="literal">
        session_status
       </code>
      </a>
      , this column
            contains the variable value for the current session.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
    <code class="literal">
     global_status
    </code>
   </a>
   and
   <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
    <code class="literal">
     session_status
    </code>
   </a>
   tables have these
        indexes:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Primary key on (
      <code class="literal">
       VARIABLE_NAME
      </code>
      )
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
    <code class="literal">
     status_by_thread
    </code>
   </a>
   table contains
        the status of each active thread. It has these columns:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       THREAD_ID
      </code>
     </p>
     <p>
      The thread identifier of the session in which the status
            variable is defined.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       VARIABLE_NAME
      </code>
     </p>
     <p>
      The status variable name.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       VARIABLE_VALUE
      </code>
     </p>
     <p>
      The session variable value for the session named by the
      <code class="literal">
       THREAD_ID
      </code>
      column.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
    <code class="literal">
     status_by_thread
    </code>
   </a>
   table has
        these indexes:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Primary key on (
      <code class="literal">
       THREAD_ID
      </code>
      ,
      <code class="literal">
       VARIABLE_NAME
      </code>
      )
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
    <code class="literal">
     status_by_thread
    </code>
   </a>
   table contains
        status variable information only about foreground threads. If
        the
   <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_thread_instances">
    <code class="literal">
     performance_schema_max_thread_instances
    </code>
   </a>
   system variable is not autoscaled (signified by a value of
        −1) and the maximum permitted number of instrumented
        thread objects is not greater than the number of background
        threads, the table is empty.
  </p>
  <p>
   The Performance Schema supports
   <a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
    <code class="literal">
     TRUNCATE
        TABLE
    </code>
   </a>
   for status variable tables as follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
       <code class="literal">
        global_status
       </code>
      </a>
      : Resets thread,
            account, host, and user status. Resets global status
            variables except those that the server never resets.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
       <code class="literal">
        session_status
       </code>
      </a>
      : Not supported.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
       <code class="literal">
        status_by_thread
       </code>
      </a>
      : Aggregates
            status for all threads to the global status and account
            status, then resets thread status. If account statistics are
            not collected, the session status is added to host and user
            status, if host and user status are collected.
     </p>
     <p>
      Account, host, and user statistics are not collected if the
      <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_accounts_size">
       <code class="literal">
        performance_schema_accounts_size
       </code>
      </a>
      ,
      <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_hosts_size">
       <code class="literal">
        performance_schema_hosts_size
       </code>
      </a>
      ,
            and
      <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_users_size">
       <code class="literal">
        performance_schema_users_size
       </code>
      </a>
      system variables, respectively, are set to 0.
     </p>
    </li>
   </ul>
  </div>
  <p>
   <a class="link" href="flush.html#flush-status">
    <code class="literal">
     FLUSH STATUS
    </code>
   </a>
   adds the session
        status from all active sessions to the global status variables,
        resets the status of all active sessions, and resets account,
        host, and user status values aggregated from disconnected
        sessions.
  </p>
 </div>
 <br/>
</div>
