<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="performance-schema-events-statements-current-table">
      </a>
      29.12.6.1 The events_statements_current Table
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045072837680">
  </a>
  <a class="indexterm" name="idm46045072836176">
  </a>
  <p>
   The
   <a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
    <code class="literal">
     events_statements_current
    </code>
   </a>
   table contains current statement events. The table stores one
          row per thread showing the current status of the thread's most
          recent monitored statement event, so there is no system
          variable for configuring the table size.
  </p>
  <p>
   Of the tables that contain statement event rows,
   <a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
    <code class="literal">
     events_statements_current
    </code>
   </a>
   is the
          most fundamental. Other tables that contain statement event
          rows are logically derived from the current events. For
          example, the
   <a class="link" href="performance-schema-events-statements-history-table.html" title="29.12.6.2 The events_statements_history Table">
    <code class="literal">
     events_statements_history
    </code>
   </a>
   and
   <a class="link" href="performance-schema-events-statements-history-long-table.html" title="29.12.6.3 The events_statements_history_long Table">
    <code class="literal">
     events_statements_history_long
    </code>
   </a>
   tables are collections of the most recent statement events
          that have ended, up to a maximum number of rows per thread and
          globally across all threads, respectively.
  </p>
  <p>
   For more information about the relationship between the three
   <code class="literal">
    events_statements_
    <em class="replaceable">
     <code>
      xxx
     </code>
    </em>
   </code>
   event tables, see
   <a class="xref" href="performance-schema-event-tables.html" title="29.9 Performance Schema Tables for Current and Historical Events">
    Section 29.9, “Performance Schema Tables for Current and Historical Events”
   </a>
   .
  </p>
  <p>
   For information about configuring whether to collect statement
          events, see
   <a class="xref" href="performance-schema-statement-tables.html" title="29.12.6 Performance Schema Statement Event Tables">
    Section 29.12.6, “Performance Schema Statement Event Tables”
   </a>
   .
  </p>
  <p>
   The
   <a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
    <code class="literal">
     events_statements_current
    </code>
   </a>
   table 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>
      ,
      <code class="literal">
       EVENT_ID
      </code>
     </p>
     <p>
      The thread associated with the event and the thread
              current event number when the event starts. The
      <code class="literal">
       THREAD_ID
      </code>
      and
      <code class="literal">
       EVENT_ID
      </code>
      values taken together uniquely
              identify the row. No two rows have the same pair of
              values.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       END_EVENT_ID
      </code>
     </p>
     <p>
      This column is set to
      <code class="literal">
       NULL
      </code>
      when the
              event starts and updated to the thread current event
              number when the event ends.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       EVENT_NAME
      </code>
     </p>
     <p>
      The name of the instrument from which the event was
              collected. This is a
      <code class="literal">
       NAME
      </code>
      value from
              the
      <a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
       <code class="literal">
        setup_instruments
       </code>
      </a>
      table.
              Instrument names may have multiple parts and form a
              hierarchy, as discussed in
      <a class="xref" href="performance-schema-instrument-naming.html" title="29.6 Performance Schema Instrument Naming Conventions">
       Section 29.6, “Performance Schema Instrument Naming Conventions”
      </a>
      .
     </p>
     <p>
      For SQL statements, the
      <code class="literal">
       EVENT_NAME
      </code>
      value initially is
      <code class="literal">
       statement/com/Query
      </code>
      until the statement is parsed, then changes to a more
              appropriate value, as described in
      <a class="xref" href="performance-schema-statement-tables.html" title="29.12.6 Performance Schema Statement Event Tables">
       Section 29.12.6, “Performance Schema Statement Event Tables”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SOURCE
      </code>
     </p>
     <p>
      The name of the source file containing the instrumented
              code that produced the event and the line number in the
              file at which the instrumentation occurs. This enables you
              to check the source to determine exactly what code is
              involved.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       TIMER_START
      </code>
      ,
      <code class="literal">
       TIMER_END
      </code>
      ,
      <code class="literal">
       TIMER_WAIT
      </code>
     </p>
     <p>
      Timing information for the event. The unit for these
              values is picoseconds (trillionths of a second). The
      <code class="literal">
       TIMER_START
      </code>
      and
      <code class="literal">
       TIMER_END
      </code>
      values indicate when event
              timing started and ended.
      <code class="literal">
       TIMER_WAIT
      </code>
      is
              the event elapsed time (duration).
     </p>
     <p>
      If an event has not finished,
      <code class="literal">
       TIMER_END
      </code>
      is the current timer value and
      <code class="literal">
       TIMER_WAIT
      </code>
      is the time elapsed so far
              (
      <code class="literal">
       TIMER_END
      </code>
      −
      <code class="literal">
       TIMER_START
      </code>
      ).
     </p>
     <p>
      If an event is produced from an instrument that has
      <code class="literal">
       TIMED = NO
      </code>
      , timing information is not
              collected, and
      <code class="literal">
       TIMER_START
      </code>
      ,
      <code class="literal">
       TIMER_END
      </code>
      , and
      <code class="literal">
       TIMER_WAIT
      </code>
      are all
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <p>
      For discussion of picoseconds as the unit for event times
              and factors that affect time values, see
      <a class="xref" href="performance-schema-timing.html" title="29.4.1 Performance Schema Event Timing">
       Section 29.4.1, “Performance Schema Event Timing”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       LOCK_TIME
      </code>
     </p>
     <p>
      The time spent waiting for table locks. This value is
              computed in microseconds but normalized to picoseconds for
              easier comparison with other Performance Schema timers.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SQL_TEXT
      </code>
     </p>
     <p>
      The text of the SQL statement. For a command not
              associated with an SQL statement, the value is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <p>
      The maximum space available for statement display is 1024
              bytes by default. To change this value, set the
      <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_sql_text_length">
       <code class="literal">
        performance_schema_max_sql_text_length
       </code>
      </a>
      system variable at server startup. (Changing this value
              affects columns in other Performance Schema tables as
              well. See
      <a class="xref" href="performance-schema-statement-digests.html" title="29.10 Performance Schema Statement Digests and Sampling">
       Section 29.10, “Performance Schema Statement Digests and Sampling”
      </a>
      .)
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       DIGEST
      </code>
     </p>
     <p>
      The statement digest SHA-256 value as a string of 64
              hexadecimal characters, or
      <code class="literal">
       NULL
      </code>
      if the
      <code class="literal">
       statements_digest
      </code>
      consumer is
      <code class="literal">
       no
      </code>
      . For more information about
              statement digesting, see
      <a class="xref" href="performance-schema-statement-digests.html" title="29.10 Performance Schema Statement Digests and Sampling">
       Section 29.10, “Performance Schema Statement Digests and Sampling”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       DIGEST_TEXT
      </code>
     </p>
     <p>
      The normalized statement digest text, or
      <code class="literal">
       NULL
      </code>
      if the
      <code class="literal">
       statements_digest
      </code>
      consumer is
      <code class="literal">
       no
      </code>
      . For more information about
              statement digesting, see
      <a class="xref" href="performance-schema-statement-digests.html" title="29.10 Performance Schema Statement Digests and Sampling">
       Section 29.10, “Performance Schema Statement Digests and Sampling”
      </a>
      .
     </p>
     <p>
      The
      <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
       <code class="literal">
        performance_schema_max_digest_length
       </code>
      </a>
      system variable determines the maximum number of bytes
              available per session for digest value storage. However,
              the display length of statement digests may be longer than
              the available buffer size due to encoding of statement
              elements such as keywords and literal values in digest
              buffer. Consequently, values selected from the
      <code class="literal">
       DIGEST_TEXT
      </code>
      column of statement event
              tables may appear to exceed the
      <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
       <code class="literal">
        performance_schema_max_digest_length
       </code>
      </a>
      value.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       CURRENT_SCHEMA
      </code>
     </p>
     <p>
      The default database for the statement,
      <code class="literal">
       NULL
      </code>
      if there is none.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       OBJECT_SCHEMA
      </code>
      ,
      <code class="literal">
       OBJECT_NAME
      </code>
      ,
      <code class="literal">
       OBJECT_TYPE
      </code>
     </p>
     <p>
      For nested statements (stored programs), these columns
              contain information about the parent statement. Otherwise
              they are
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       OBJECT_INSTANCE_BEGIN
      </code>
     </p>
     <p>
      This column identifies the statement. The value is the
              address of an object in memory.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       MYSQL_ERRNO
      </code>
     </p>
     <p>
      The statement error number, from the statement diagnostics
              area.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       RETURNED_SQLSTATE
      </code>
     </p>
     <p>
      The statement SQLSTATE value, from the statement
              diagnostics area.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       MESSAGE_TEXT
      </code>
     </p>
     <p>
      The statement error message, from the statement
              diagnostics area.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       ERRORS
      </code>
     </p>
     <p>
      Whether an error occurred for the statement. The value is
              0 if the SQLSTATE value begins with
      <code class="literal">
       00
      </code>
      (completion) or
      <code class="literal">
       01
      </code>
      (warning). The value
              is 1 is the SQLSTATE value is anything else.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       WARNINGS
      </code>
     </p>
     <p>
      The number of warnings, from the statement diagnostics
              area.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       ROWS_AFFECTED
      </code>
     </p>
     <p>
      The number of rows affected by the statement. For a
              description of the meaning of
      <span class="quote">
       “
       <span class="quote">
        affected,
       </span>
       ”
      </span>
      see
      <a class="ulink" href="/doc/c-api/8.4/en/mysql-affected-rows.html" target="_top">
       mysql_affected_rows()
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       ROWS_SENT
      </code>
     </p>
     <p>
      The number of rows returned by the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       ROWS_EXAMINED
      </code>
     </p>
     <p>
      The number of rows examined by the server layer (not
              counting any processing internal to storage engines).
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       CREATED_TMP_DISK_TABLES
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Created_tmp_disk_tables">
       <code class="literal">
        Created_tmp_disk_tables
       </code>
      </a>
      status variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       CREATED_TMP_TABLES
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Created_tmp_tables">
       <code class="literal">
        Created_tmp_tables
       </code>
      </a>
      status variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SELECT_FULL_JOIN
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Select_full_join">
       <code class="literal">
        Select_full_join
       </code>
      </a>
      status
              variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SELECT_FULL_RANGE_JOIN
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Select_full_range_join">
       <code class="literal">
        Select_full_range_join
       </code>
      </a>
      status variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SELECT_RANGE
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Select_range">
       <code class="literal">
        Select_range
       </code>
      </a>
      status variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SELECT_RANGE_CHECK
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Select_range_check">
       <code class="literal">
        Select_range_check
       </code>
      </a>
      status variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SELECT_SCAN
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Select_scan">
       <code class="literal">
        Select_scan
       </code>
      </a>
      status variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SORT_MERGE_PASSES
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Sort_merge_passes">
       <code class="literal">
        Sort_merge_passes
       </code>
      </a>
      status
              variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SORT_RANGE
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Sort_range">
       <code class="literal">
        Sort_range
       </code>
      </a>
      status variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SORT_ROWS
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Sort_rows">
       <code class="literal">
        Sort_rows
       </code>
      </a>
      status variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SORT_SCAN
      </code>
     </p>
     <p>
      Like the
      <a class="link" href="server-status-variables.html#statvar_Sort_scan">
       <code class="literal">
        Sort_scan
       </code>
      </a>
      status variable, but specific to the statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       NO_INDEX_USED
      </code>
     </p>
     <p>
      1 if the statement performed a table scan without using an
              index, 0 otherwise.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       NO_GOOD_INDEX_USED
      </code>
     </p>
     <p>
      1 if the server found no good index to use for the
              statement, 0 otherwise. For additional information, see
              the description of the
      <code class="literal">
       Extra
      </code>
      column
              from
      <code class="literal">
       EXPLAIN
      </code>
      output for the
      <code class="literal">
       Range checked for each record
      </code>
      value in
      <a class="xref" href="explain-output.html" title="10.8.2 EXPLAIN Output Format">
       Section 10.8.2, “EXPLAIN Output Format”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       NESTING_EVENT_ID
      </code>
      ,
      <code class="literal">
       NESTING_EVENT_TYPE
      </code>
      ,
      <code class="literal">
       NESTING_EVENT_LEVEL
      </code>
     </p>
     <p>
      These three columns are used with other columns to provide
              information as follows for top-level (unnested) statements
              and nested statements (executed within a stored program).
     </p>
     <p>
      For top level statements:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-none"><div class="docs-select-all right" id="sa16458745"><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-none">OBJECT_TYPE = NULL
OBJECT_SCHEMA = NULL
OBJECT_NAME = NULL
NESTING_EVENT_ID = the parent transaction EVENT_ID
NESTING_EVENT_TYPE = 'TRANSACTION'
NESTING_LEVEL = 0</code></pre>
     </div>
     <p>
      For nested statements:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-none"><div class="docs-select-all right" id="sa20942061"><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-none">OBJECT_TYPE = the parent statement object type
OBJECT_SCHEMA = the parent statement object schema
OBJECT_NAME = the parent statement object name
NESTING_EVENT_ID = the parent statement EVENT_ID
NESTING_EVENT_TYPE = 'STATEMENT'
NESTING_LEVEL = the parent statement NESTING_LEVEL plus one</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       STATEMENT_ID
      </code>
     </p>
     <p>
      The query ID maintained by the server at the SQL level.
              The value is unique for the server instance because these
              IDs are generated using a global counter that is
              incremented atomically.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       CPU_TIME
      </code>
     </p>
     <p>
      The time spent on CPU for the current thread, expressed in
              picoseconds.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       MAX_CONTROLLED_MEMORY
      </code>
     </p>
     <p>
      Reports the maximum amount of controlled memory used by a
              statement during execution.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       MAX_TOTAL_MEMORY
      </code>
     </p>
     <p>
      Reports the maximum amount of memory used by a statement
              during execution.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       EXECUTION_ENGINE
      </code>
     </p>
     <p>
      The query execution engine. The value is either
      <code class="literal">
       PRIMARY
      </code>
      or
      <code class="literal">
       SECONDARY
      </code>
      . For use with HeatWave Service and
              HeatWave, where the
      <code class="literal">
       PRIMARY
      </code>
      engine is
      <code class="literal">
       InnoDB
      </code>
      and the
      <code class="literal">
       SECONDARY
      </code>
      engine is HeatWave
              (
      <code class="literal">
       RAPID
      </code>
      ). For MySQL Community Edition Server, MySQL Enterprise Edition Server
              (on-premise), and HeatWave Service without HeatWave, the value is
              always
      <code class="literal">
       PRIMARY
      </code>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
    <code class="literal">
     events_statements_current
    </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">
       EVENT_ID
      </code>
      )
     </p>
    </li>
   </ul>
  </div>
  <p>
   <a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
    <code class="literal">
     TRUNCATE TABLE
    </code>
   </a>
   is permitted for
          the
   <a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
    <code class="literal">
     events_statements_current
    </code>
   </a>
   table. It removes the rows.
  </p>
 </div>
 <br/>
</div>
