<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="performance-schema-transaction-tables">
      </a>
      29.12.7 Performance Schema Transaction Tables
     </h3>
    </div>
   </div>
  </div>
  <div class="toc">
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="performance-schema-events-transactions-current-table.html">
       29.12.7.1 The events_transactions_current Table
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-events-transactions-history-table.html">
       29.12.7.2 The events_transactions_history Table
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="performance-schema-events-transactions-history-long-table.html">
       29.12.7.3 The events_transactions_history_long Table
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <p>
   The Performance Schema instruments transactions. Within the
        event hierarchy, wait events nest within stage events, which
        nest within statement events, which nest within transaction
        events.
  </p>
  <p>
   These tables store transaction events:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-events-transactions-current-table.html" title="29.12.7.1 The events_transactions_current Table">
       <code class="literal">
        events_transactions_current
       </code>
      </a>
      :
            The current transaction event for each thread.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-events-transactions-history-table.html" title="29.12.7.2 The events_transactions_history Table">
       <code class="literal">
        events_transactions_history
       </code>
      </a>
      :
            The most recent transaction events that have ended per
            thread.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="performance-schema-events-transactions-history-long-table.html" title="29.12.7.3 The events_transactions_history_long Table">
       <code class="literal">
        events_transactions_history_long
       </code>
      </a>
      :
            The most recent transaction events that have ended globally
            (across all threads).
     </p>
    </li>
   </ul>
  </div>
  <p>
   The following sections describe the transaction event tables.
        There are also summary tables that aggregate information about
        transaction events; see
   <a class="xref" href="performance-schema-transaction-summary-tables.html" title="29.12.20.5 Transaction Summary Tables">
    Section 29.12.20.5, “Transaction Summary Tables”
   </a>
   .
  </p>
  <p>
   For more information about the relationship between the three
        transaction 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>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="performance-schema-transaction-tables.html#performance-schema-transaction-tables-configuration" title="Configuring Transaction Event Collection">
       Configuring Transaction Event Collection
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="performance-schema-transaction-tables.html#performance-schema-transaction-tables-transaction-boundaries" title="Transaction Boundaries">
       Transaction Boundaries
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="performance-schema-transaction-tables.html#performance-schema-transaction-tables-instrumentation" title="Transaction Instrumentation">
       Transaction Instrumentation
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="performance-schema-transaction-tables.html#performance-schema-transaction-tables-nested-events" title="Transactions and Nested Events">
       Transactions and Nested Events
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="performance-schema-transaction-tables.html#performance-schema-transaction-tables-stored-programs" title="Transactions and Stored Programs">
       Transactions and Stored Programs
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="performance-schema-transaction-tables.html#performance-schema-transaction-tables-savepoints" title="Transactions and Savepoints">
       Transactions and Savepoints
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="performance-schema-transaction-tables.html#performance-schema-transaction-tables-errors" title="Transactions and Errors">
       Transactions and Errors
      </a>
     </p>
    </li>
   </ul>
  </div>
  <h4>
   <a name="performance-schema-transaction-tables-configuration">
   </a>
   Configuring Transaction Event Collection
  </h4>
  <p>
   To control whether to collect transaction events, set the state
        of the relevant instruments and consumers:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      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
            contains an instrument named
      <code class="literal">
       transaction
      </code>
      .
            Use this instrument to enable or disable collection of
            individual transaction event classes.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
       <code class="literal">
        setup_consumers
       </code>
      </a>
      table
            contains consumer values with names corresponding to the
            current and historical transaction event table names. Use
            these consumers to filter collection of transaction events.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <code class="literal">
    transaction
   </code>
   instrument and the
   <code class="literal">
    events_transactions_current
   </code>
   and
   <code class="literal">
    events_transactions_history
   </code>
   transaction
        consumers are enabled by default:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96019525"><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> <span class="token keyword">NAME</span><span class="token punctuation">,</span> ENABLED<span class="token punctuation">,</span> TIMED
       <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_instruments
       <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">=</span> <span class="token string">'transaction'</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 class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME        <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> TIMED <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 class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> transaction <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span> YES   <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 class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span>
       <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers
       <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_transactions%'</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 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> NAME                             <span class="token punctuation">|</span> ENABLED <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 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> events_transactions_current      <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history      <span class="token punctuation">|</span> YES     <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history_long <span class="token punctuation">|</span> NO      <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 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>
   To control transaction event collection at server startup, use
        lines like these in your
   <code class="filename">
    my.cnf
   </code>
   file:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Enable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa5890499"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'transaction=ON'</span>
<span class="token constant">performance-schema-consumer-events-transactions-current</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span>
<span class="token constant">performance-schema-consumer-events-transactions-history</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span>
<span class="token constant">performance-schema-consumer-events-transactions-history-long</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Disable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa36179360"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'transaction=OFF'</span>
<span class="token constant">performance-schema-consumer-events-transactions-current</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span>
<span class="token constant">performance-schema-consumer-events-transactions-history</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span>
<span class="token constant">performance-schema-consumer-events-transactions-history-long</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   To control transaction event collection at runtime, update 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>
   and
   <a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
    <code class="literal">
     setup_consumers
    </code>
   </a>
   tables:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Enable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa73659289"><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">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">=</span> <span class="token string">'transaction'</span><span class="token punctuation">;</span>

<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_transactions%'</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Disable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33250019"><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">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">=</span> <span class="token string">'transaction'</span><span class="token punctuation">;</span>

<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_transactions%'</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   To collect transaction events only for specific transaction
        event tables, enable the
   <code class="literal">
    transaction
   </code>
   instrument but only the transaction consumers corresponding to
        the desired tables.
  </p>
  <p>
   For additional information about configuring event collection,
        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>
   ,
        and
   <a class="xref" href="performance-schema-runtime-configuration.html" title="29.4 Performance Schema Runtime Configuration">
    Section 29.4, “Performance Schema Runtime Configuration”
   </a>
   .
  </p>
  <h4>
   <a name="performance-schema-transaction-tables-transaction-boundaries">
   </a>
   Transaction Boundaries
  </h4>
  <p>
   In MySQL Server, transactions start explicitly with these
        statements:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa12730215"><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">START</span> <span class="token keyword">TRANSACTION</span> <span class="token operator">|</span> <span class="token keyword">BEGIN</span> <span class="token operator">|</span> <span class="token keyword">XA</span> <span class="token keyword">START</span> <span class="token operator">|</span> <span class="token keyword">XA</span> <span class="token keyword">BEGIN</span></code></pre>
  </div>
  <p>
   Transactions also start implicitly. For example, when the
   <a class="link" href="server-system-variables.html#sysvar_autocommit">
    <code class="literal">
     autocommit
    </code>
   </a>
   system variable is
        enabled, the start of each statement starts a new transaction.
  </p>
  <p>
   When
   <a class="link" href="server-system-variables.html#sysvar_autocommit">
    <code class="literal">
     autocommit
    </code>
   </a>
   is disabled,
        the first statement following a committed transaction marks the
        start of a new transaction. Subsequent statements are part of
        the transaction until it is committed.
  </p>
  <p>
   Transactions explicitly end with these statements:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa2941245"><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">COMMIT</span> <span class="token operator">|</span> <span class="token keyword">ROLLBACK</span> <span class="token operator">|</span> <span class="token keyword">XA</span> <span class="token keyword">COMMIT</span> <span class="token operator">|</span> <span class="token keyword">XA</span> <span class="token keyword">ROLLBACK</span></code></pre>
  </div>
  <p>
   Transactions also end implicitly, by execution of DDL
        statements, locking statements, and server administration
        statements.
  </p>
  <p>
   In the following discussion, references to
   <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
    <code class="literal">
     START
        TRANSACTION
    </code>
   </a>
   also apply to
   <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
    <code class="literal">
     BEGIN
    </code>
   </a>
   ,
   <a class="link" href="xa-statements.html" title="15.3.8.1 XA Transaction SQL Statements">
    <code class="literal">
     XA
        START
    </code>
   </a>
   , and
   <a class="link" href="xa-statements.html" title="15.3.8.1 XA Transaction SQL Statements">
    <code class="literal">
     XA
        BEGIN
    </code>
   </a>
   . Similarly, references to
   <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
    <code class="literal">
     COMMIT
    </code>
   </a>
   and
   <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
    <code class="literal">
     ROLLBACK
    </code>
   </a>
   apply
        to
   <a class="link" href="xa-statements.html" title="15.3.8.1 XA Transaction SQL Statements">
    <code class="literal">
     XA
        COMMIT
    </code>
   </a>
   and
   <a class="link" href="xa-statements.html" title="15.3.8.1 XA Transaction SQL Statements">
    <code class="literal">
     XA
        ROLLBACK
    </code>
   </a>
   , respectively.
  </p>
  <p>
   The Performance Schema defines transaction boundaries similarly
        to that of the server. The start and end of a transaction event
        closely match the corresponding state transitions in the server:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      For an explicitly started transaction, the transaction event
            starts during processing of the
      <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
       <code class="literal">
        START
            TRANSACTION
       </code>
      </a>
      statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      For an implicitly started transaction, the transaction event
            starts on the first statement that uses a transactional
            engine after the previous transaction has ended.
     </p>
    </li>
    <li class="listitem">
     <p>
      For any transaction, whether explicitly or implicitly ended,
            the transaction event ends when the server transitions out
            of the active transaction state during the processing of
      <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
       <code class="literal">
        COMMIT
       </code>
      </a>
      or
      <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
       <code class="literal">
        ROLLBACK
       </code>
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   There are subtle implications to this approach:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Transaction events in the Performance Schema do not fully
            include the statement events associated with the
            corresponding
      <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
       <code class="literal">
        START
            TRANSACTION
       </code>
      </a>
      ,
      <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
       <code class="literal">
        COMMIT
       </code>
      </a>
      , or
      <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
       <code class="literal">
        ROLLBACK
       </code>
      </a>
      statements. There is a trivial amount of timing overlap
            between the transaction event and these statements.
     </p>
    </li>
    <li class="listitem">
     <p>
      Statements that work with nontransactional engines have no
            effect on the transaction state of the connection. For
            implicit transactions, the transaction event begins with the
            first statement that uses a transactional engine. This means
            that statements operating exclusively on nontransactional
            tables are ignored, even following
      <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
       <code class="literal">
        START
            TRANSACTION
       </code>
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   To illustrate, consider the following scenario:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-none"><div class="docs-select-all right" id="sa3424206"><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">1. SET autocommit = OFF;
2. CREATE TABLE t1 (a INT) ENGINE = InnoDB;
3. START TRANSACTION;                       -- Transaction 1 START
4. INSERT INTO t1 VALUES (1), (2), (3);
5. CREATE TABLE t2 (a INT) ENGINE = MyISAM; -- Transaction 1 COMMIT
                                            -- (implicit; DDL forces commit)
6. INSERT INTO t2 VALUES (1), (2), (3);     -- Update nontransactional table
7. UPDATE t2 SET a = a + 1;                 -- ... and again
8. INSERT INTO t1 VALUES (4), (5), (6);     -- Write to transactional table
                                            -- Transaction 2 START (implicit)
9. COMMIT;                                  -- Transaction 2 COMMIT</code></pre>
  </div>
  <p>
   From the perspective of the server, Transaction 1 ends when
        table
   <code class="literal">
    t2
   </code>
   is created. Transaction 2 does not
        start until a transactional table is accessed, despite the
        intervening updates to nontransactional tables.
  </p>
  <p>
   From the perspective of the Performance Schema, Transaction 2
        starts when the server transitions into an active transaction
        state. Statements 6 and 7 are not included within the boundaries
        of Transaction 2, which is consistent with how the server writes
        transactions to the binary log.
  </p>
  <h4>
   <a name="performance-schema-transaction-tables-instrumentation">
   </a>
   Transaction Instrumentation
  </h4>
  <p>
   Three attributes define transactions:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Access mode (read only, read write)
     </p>
    </li>
    <li class="listitem">
     <p>
      Isolation level
            (
      <a class="link" href="innodb-transaction-isolation-levels.html#isolevel_serializable">
       <code class="literal">
        SERIALIZABLE
       </code>
      </a>
      ,
      <a class="link" href="innodb-transaction-isolation-levels.html#isolevel_repeatable-read">
       <code class="literal">
        REPEATABLE READ
       </code>
      </a>
      , and so
            forth)
     </p>
    </li>
    <li class="listitem">
     <p>
      Implicit (
      <a class="link" href="server-system-variables.html#sysvar_autocommit">
       <code class="literal">
        autocommit
       </code>
      </a>
      enabled) or explicit
            (
      <a class="link" href="server-system-variables.html#sysvar_autocommit">
       <code class="literal">
        autocommit
       </code>
      </a>
      disabled)
     </p>
    </li>
   </ul>
  </div>
  <p>
   To reduce complexity of the transaction instrumentation and to
        ensure that the collected transaction data provides complete,
        meaningful results, all transactions are instrumented
        independently of access mode, isolation level, or autocommit
        mode.
  </p>
  <p>
   To selectively examine transaction history, use the attribute
        columns in the transaction event tables:
   <code class="literal">
    ACCESS_MODE
   </code>
   ,
   <code class="literal">
    ISOLATION_LEVEL
   </code>
   , and
   <code class="literal">
    AUTOCOMMIT
   </code>
   .
  </p>
  <p>
   The cost of transaction instrumentation can be reduced various
        ways, such as enabling or disabling transaction instrumentation
        according to user, account, host, or thread (client connection).
  </p>
  <h4>
   <a name="performance-schema-transaction-tables-nested-events">
   </a>
   Transactions and Nested Events
  </h4>
  <p>
   The parent of a transaction event is the event that initiated
        the transaction. For an explicitly started transaction, this
        includes the
   <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
    <code class="literal">
     START
        TRANSACTION
    </code>
   </a>
   and
   <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
    <code class="literal">
     COMMIT AND
        CHAIN
    </code>
   </a>
   statements. For an implicitly started
        transaction, it is the first statement that uses a transactional
        engine after the previous transaction ends.
  </p>
  <p>
   In general, a transaction is the top-level parent to all events
        initiated during the transaction, including statements that
        explicitly end the transaction such as
   <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
    <code class="literal">
     COMMIT
    </code>
   </a>
   and
   <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
    <code class="literal">
     ROLLBACK
    </code>
   </a>
   .
        Exceptions are statements that implicitly end a transaction,
        such as DDL statements, in which case the current transaction
        must be committed before the new statement is executed.
  </p>
  <h4>
   <a name="performance-schema-transaction-tables-stored-programs">
   </a>
   Transactions and Stored Programs
  </h4>
  <p>
   Transactions and stored program events are related as follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Stored Procedures
     </p>
     <p>
      Stored procedures operate independently of transactions. A
            stored procedure can be started within a transaction, and a
            transaction can be started or ended from within a stored
            procedure. If called from within a transaction, a stored
            procedure can execute statements that force a commit of the
            parent transaction and then start a new transaction.
     </p>
     <p>
      If a stored procedure is started within a transaction, that
            transaction is the parent of the stored procedure event.
     </p>
     <p>
      If a transaction is started by a stored procedure, the
            stored procedure is the parent of the transaction event.
     </p>
    </li>
    <li class="listitem">
     <p>
      Stored Functions
     </p>
     <p>
      Stored functions are restricted from causing an explicit or
            implicit commit or rollback. Stored function events can
            reside within a parent transaction event.
     </p>
    </li>
    <li class="listitem">
     <p>
      Triggers
     </p>
     <p>
      Triggers activate as part of a statement that accesses the
            table with which it is associated, so the parent of a
            trigger event is always the statement that activates it.
     </p>
     <p>
      Triggers cannot issue statements that cause an explicit or
            implicit commit or rollback of a transaction.
     </p>
    </li>
    <li class="listitem">
     <p>
      Scheduled Events
     </p>
     <p>
      The execution of the statements in the body of a scheduled
            event takes place in a new connection. Nesting of a
            scheduled event within a parent transaction is not
            applicable.
     </p>
    </li>
   </ul>
  </div>
  <h4>
   <a name="performance-schema-transaction-tables-savepoints">
   </a>
   Transactions and Savepoints
  </h4>
  <p>
   Savepoint statements are recorded as separate statement events.
        Transaction events include separate counters for
   <a class="link" href="savepoint.html" title="15.3.4 SAVEPOINT, ROLLBACK TO SAVEPOINT, and RELEASE SAVEPOINT Statements">
    <code class="literal">
     SAVEPOINT
    </code>
   </a>
   ,
   <a class="link" href="savepoint.html" title="15.3.4 SAVEPOINT, ROLLBACK TO SAVEPOINT, and RELEASE SAVEPOINT Statements">
    <code class="literal">
     ROLLBACK TO
        SAVEPOINT
    </code>
   </a>
   , and
   <a class="link" href="savepoint.html" title="15.3.4 SAVEPOINT, ROLLBACK TO SAVEPOINT, and RELEASE SAVEPOINT Statements">
    <code class="literal">
     RELEASE
        SAVEPOINT
    </code>
   </a>
   statements issued during the transaction.
  </p>
  <h4>
   <a name="performance-schema-transaction-tables-errors">
   </a>
   Transactions and Errors
  </h4>
  <p>
   Errors and warnings that occur within a transaction are recorded
        in statement events, but not in the corresponding transaction
        event. This includes transaction-specific errors and warnings,
        such as a rollback on a nontransactional table or GTID
        consistency errors.
  </p>
 </div>
 <br/>
</div>
