<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="replication-gtids-concepts">
      </a>
      19.1.3.1 GTID Format and Storage
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045146422960">
  </a>
  <p>
   A global transaction identifier (GTID) is a unique identifier
      created and associated with each transaction committed on the
      server of origin (the source). This identifier is unique not only
      to the server on which it originated, but is unique across all
      servers in a given replication topology.
  </p>
  <p>
   GTID assignment distinguishes between client transactions, which
      are committed on the source, and replicated transactions, which
      are reproduced on a replica. When a client transaction is
      committed on the source, it is assigned a new GTID, provided that
      the transaction was written to the binary log. Client transactions
      are guaranteed to have monotonically increasing GTIDs without gaps
      between the generated numbers. If a client transaction is not
      written to the binary log (for example, because the transaction
      was filtered out, or the transaction was read-only), it is not
      assigned a GTID on the server of origin.
  </p>
  <p>
   Replicated transactions retain the same GTID that was assigned to
      the transaction on the server of origin. The GTID is present
      before the replicated transaction begins to execute, and is
      persisted even if the replicated transaction is not written to the
      binary log on the replica, or is filtered out on the replica. The
   <code class="literal">
    mysql.gtid_executed
   </code>
   system table is used to
      preserve the assigned GTIDs of all the transactions applied on a
      MySQL server, except those that are stored in a currently active
      binary log file.
  </p>
  <p>
   The auto-skip function for GTIDs means that a transaction
      committed on the source can be applied no more than once on the
      replica, which helps to guarantee consistency. Once a transaction
      with a given GTID has been committed on a given server, any
      attempt to execute a subsequent transaction with the same GTID is
      ignored by that server. No error is raised, and no statement in
      the transaction is executed.
  </p>
  <p>
   If a transaction with a given GTID has started to execute on a
      server, but has not yet committed or rolled back, any attempt to
      start a concurrent transaction on the server with the same GTID
      blocks. The server neither begins to execute the concurrent
      transaction nor returns control to the client. Once the first
      attempt at the transaction commits or rolls back, concurrent
      sessions that were blocking on the same GTID may proceed. If the
      first attempt rolled back, one concurrent session proceeds to
      attempt the transaction, and any other concurrent sessions that
      were blocking on the same GTID remain blocked. If the first
      attempt committed, all the concurrent sessions stop being blocked,
      and auto-skip all the statements of the transaction.
  </p>
  <p>
   A GTID is represented as a pair of coordinates, separated by a
      colon character (
   <code class="literal">
    :
   </code>
   ), as shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-ini"><div class="docs-select-all right" id="sa62256146"><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 constant">GTID</span> <span class="token attr-value"><span class="token punctuation">=</span> <em class="replaceable">source_id</em>:<em class="replaceable">transaction_id</em></span></code></pre>
  </div>
  <p>
   The
   <em class="replaceable">
    <code>
     source_id
    </code>
   </em>
   identifies the
      originating server. Normally, the source's
   <a class="link" href="replication-options.html#sysvar_server_uuid">
    <code class="literal">
     server_uuid
    </code>
   </a>
   is used for this
      purpose. The
   <em class="replaceable">
    <code>
     transaction_id
    </code>
   </em>
   is a
      sequence number determined by the order in which the transaction
      was committed on the source. For example, the first transaction to
      be committed has
   <code class="literal">
    1
   </code>
   as its
   <em class="replaceable">
    <code>
     transaction_id
    </code>
   </em>
   , and the tenth
      transaction to be committed on the same originating server is
      assigned a
   <em class="replaceable">
    <code>
     transaction_id
    </code>
   </em>
   of
   <code class="literal">
    10
   </code>
   . It is not possible for a transaction to
      have
   <code class="literal">
    0
   </code>
   as a sequence number in a GTID. For
      example, the twenty-third transaction to be committed originally
      on the server with the UUID
   <code class="literal">
    3E11FA47-71CA-11E1-9E33-C80AA9429562
   </code>
   has this
      GTID:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa87453132"><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">3E11FA47-71CA-11E1-9E33-C80AA9429562:23</code></pre>
  </div>
  <p>
   The upper limit for sequence numbers for GTIDs on a server
      instance is the number of non-negative values for a signed 64-bit
      integer (
   <code class="literal">
    2
    <sup>
     63
    </sup>
    - 1
   </code>
   , or
   <code class="literal">
    9223372036854775807
   </code>
   ). If the server runs out of
      GTIDs, it takes the action specified by
   <a class="link" href="replication-options-binary-log.html#sysvar_binlog_error_action">
    <code class="literal">
     binlog_error_action
    </code>
   </a>
   . A warning
      message is issued when the server instance is approaching the
      limit.
  </p>
  <p>
   MySQL 8.4 also supports tagged GTIDs. A tagged GTID
      consists of three parts, separated by colon characters, as shown
      here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-ini"><div class="docs-select-all right" id="sa47333172"><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 constant">GTID</span> <span class="token attr-value"><span class="token punctuation">=</span> <em class="replaceable">source_id</em>:<em class="replaceable">tag</em>:<em class="replaceable">transaction_id</em></span></code></pre>
  </div>
  <p>
   In this case, the
   <em class="replaceable">
    <code>
     source_id
    </code>
   </em>
   and
   <em class="replaceable">
    <code>
     transaction_id
    </code>
   </em>
   are as defined
      previously. The
   <em class="replaceable">
    <code>
     tag
    </code>
   </em>
   is a user-defined
      string used to identify a specific group of transactions; see the
      description of the
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_next">
    <code class="literal">
     gtid_next
    </code>
   </a>
   system variable for permitted syntax.
   <span class="emphasis">
    <em>
     Example
    </em>
   </span>
   : the one-hundred-seventeenth
      transaction to be committed originally on the server with the UUID
   <code class="literal">
    ed102faf-eb00-11eb-8f20-0c5415bfaa1d
   </code>
   and the
      tag
   <code class="literal">
    Domain_1
   </code>
   has this GTID:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa99473791"><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">ed102faf-eb00-11eb-8f20-0c5415bfaa1d:Domain_1:117</code></pre>
  </div>
  <p>
   The GTID for a transaction is shown in the output from
   <a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
    <span class="command">
     <strong>
      mysqlbinlog
     </strong>
    </span>
   </a>
   , and it is used to identify an
      individual transaction in the Performance Schema replication
      status tables, for example,
   <a class="link" href="performance-schema-replication-applier-status-by-worker-table.html" title="29.12.11.7 The replication_applier_status_by_worker Table">
    <code class="literal">
     replication_applier_status_by_worker
    </code>
   </a>
   .
      The value stored by the
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_next">
    <code class="literal">
     gtid_next
    </code>
   </a>
   system variable (
   <code class="literal">
    @@GLOBAL.gtid_next
   </code>
   ) is a
      single GTID.
  </p>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="replication-gtids-concepts-gtid-sets">
       </a>
       GTID Sets
      </h5>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045146385536">
   </a>
   <p>
    A GTID set is a set comprising one or more single GTIDs or
        ranges of GTIDs. GTID sets are used in a MySQL server in several
        ways. For example, the values stored by the
    <a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
     <code class="literal">
      gtid_executed
     </code>
    </a>
    and
    <a class="link" href="replication-options-gtids.html#sysvar_gtid_purged">
     <code class="literal">
      gtid_purged
     </code>
    </a>
    system variables
        are GTID sets. The
    <a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
     <code class="literal">
      START REPLICA
     </code>
    </a>
    options
    <code class="literal">
     UNTIL SQL_BEFORE_GTIDS
    </code>
    and
    <code class="literal">
     UNTIL SQL_AFTER_GTIDS
    </code>
    can be used to make a
        replica process transactions only up to the first GTID in a GTID
        set, or stop after the last GTID in a GTID set. The built-in
        functions
    <a class="link" href="gtid-functions.html#function_gtid-subset">
     <code class="literal">
      GTID_SUBSET()
     </code>
    </a>
    and
    <a class="link" href="gtid-functions.html#function_gtid-subtract">
     <code class="literal">
      GTID_SUBTRACT()
     </code>
    </a>
    require GTID sets
        as input.
   </p>
   <p>
    A range of GTIDs originating from the same server can be
        collapsed into a single expression, as shown here:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa25351248"><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">3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5</code></pre>
   </div>
   <p>
    The above example represents the first through fifth
        transactions originating on the MySQL server whose
    <a class="link" href="replication-options.html#sysvar_server_uuid">
     <code class="literal">
      server_uuid
     </code>
    </a>
    is
    <code class="literal">
     3E11FA47-71CA-11E1-9E33-C80AA9429562
    </code>
    .
        Multiple single GTIDs or ranges of GTIDs originating from the
        same server can also be included in a single expression, with
        the GTIDs or ranges separated by colons, as in the following
        example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa66354980"><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">3E11FA47-71CA-11E1-9E33-C80AA9429562:1-3:11:47-49</code></pre>
   </div>
   <p>
    A GTID set can include any combination of single GTIDs and
        ranges of GTIDs, and it can include GTIDs originating from
        different servers. This example shows the GTID set stored in the
    <a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
     <code class="literal">
      gtid_executed
     </code>
    </a>
    system variable
        (
    <code class="literal">
     @@GLOBAL.gtid_executed
    </code>
    ) of a replica that
        has applied transactions from more than one source:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa73106889"><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">2174B383-5441-11E8-B90A-C80AA9429562:1-3, 24DA167-0C0C-11E8-8442-00059A3C7B00:1-19</code></pre>
   </div>
   <p>
    When GTID sets are returned from server variables, UUIDs are in
        alphabetical order, and numeric intervals are merged and in
        ascending order.
   </p>
   <p>
    When constructing a GTID set, a user-defined tag is treated as
        part of the UUID. This means that multiple GTIDs originating
        from the same server and having the same tag can be included in
        a single expression, as shown in this example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa34193782"><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">3E11FA47-71CA-11E1-9E33-C80AA9429562:Domain_1:1-3:11:47-49</code></pre>
   </div>
   <p>
    GTIDs originating from the same server but having different tags
        are treated in a manner similar to those originating from
        different servers, like this:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa89231599"><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">3E11FA47-71CA-11E1-9E33-C80AA9429562:Domain_1:1-3:15-21, 3E11FA47-71CA-11E1-9E33-C80AA9429562:Domain_2:8-52</code></pre>
   </div>
   <p>
    The complete syntax for a GTID set is as follows:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa59810557"><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"><em class="replaceable">gtid_set</em>:
    <em class="replaceable">uuid_set</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">uuid_set</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token operator">|</span> <span class="token string">''</span>

<em class="replaceable">uuid_set</em>:
    <em class="replaceable">uuid</em>:<span class="token punctuation">[</span><em class="replaceable">tag</em>:<span class="token punctuation">]</span><span class="token keyword"><em class="replaceable">interval</em></span><span class="token punctuation">[</span>:<span class="token keyword"><em class="replaceable">interval</em></span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

<em class="replaceable">uuid</em>:
    <em class="replaceable">hhhhhhhh</em><span class="token operator">-</span><em class="replaceable">hhhh</em><span class="token operator">-</span><em class="replaceable">hhhh</em><span class="token operator">-</span><em class="replaceable">hhhh</em><span class="token operator">-</span><em class="replaceable">hhhhhhhhhhhh</em>

<em class="replaceable">h</em>:
    <span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token operator">|</span>A<span class="token operator">-</span>F<span class="token punctuation">]</span>

<em class="replaceable">tag</em>:
    <span class="token punctuation">[</span>a<span class="token operator">-</span>z_<span class="token punctuation">]</span><span class="token punctuation">[</span>a<span class="token operator">-</span>z0<span class="token operator">-</span>9_<span class="token punctuation">]</span>{<span class="token number">0</span><span class="token punctuation">,</span><span class="token number">31</span>}

<span class="token keyword"><em class="replaceable">interval</em></span>:
    <em class="replaceable">m</em><span class="token punctuation">[</span><span class="token operator">-</span><em class="replaceable">n</em><span class="token punctuation">]</span>

    <span class="token punctuation">(</span><em class="replaceable">m</em> <span class="token operator">&gt;=</span> <span class="token number">1</span><span class="token punctuation">;</span> <em class="replaceable">n</em> <span class="token operator">&gt;</span> <em class="replaceable">m</em><span class="token punctuation">)</span></code></pre>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="replication-gtids-gtid-executed-table">
       </a>
       mysql.gtid_executed Table
      </h5>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045146351088">
   </a>
   <a class="indexterm" name="idm46045146350000">
   </a>
   <a class="indexterm" name="idm46045146348512">
   </a>
   <a class="indexterm" name="idm46045146347024">
   </a>
   <a class="indexterm" name="idm46045146345536">
   </a>
   <p>
    GTIDs are stored in a table named
    <code class="literal">
     gtid_executed
    </code>
    , in the
    <code class="literal">
     mysql
    </code>
    database. A row in this table contains,
        for each GTID or set of GTIDs that it represents, the UUID of
        the originating server, the user-defined tag (if there is one),
        and the starting and ending transaction IDs of the set; for a
        row referencing only a single GTID, these last two values are
        the same.
   </p>
   <p>
    The
    <code class="literal">
     mysql.gtid_executed
    </code>
    table is created (if
        it does not already exist) when MySQL Server is installed or
        upgraded, using a
    <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
     <code class="literal">
      CREATE TABLE
     </code>
    </a>
    statement similar to that shown here:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96346373"><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">CREATE</span> <span class="token keyword">TABLE</span> gtid_executed <span class="token punctuation">(</span>
  source_uuid <span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">36</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
  interval_start <span class="token datatype">BIGINT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
  interval_end <span class="token datatype">BIGINT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
  gtid_tag <span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">32</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
  <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>source_uuid<span class="token punctuation">,</span> gtid_tag<span class="token punctuation">,</span> interval_start<span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
   </div>
   <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Warning
    </div>
    <p>
     As with other MySQL system tables, do not attempt to create or
          modify this table yourself.
    </p>
   </div>
   <a class="indexterm" name="idm46045146336480">
   </a>
   <p>
    The
    <code class="literal">
     mysql.gtid_executed
    </code>
    table is provided for
        internal use by the MySQL server. It enables a replica to use
        GTIDs when binary logging is disabled on the replica, and it
        enables retention of the GTID state when the binary logs have
        been lost. Note that the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table is cleared if you issue
    <a class="link" href="reset-binary-logs-and-gtids.html" title="15.4.1.2 RESET BINARY LOGS AND GTIDS Statement">
     <code class="literal">
      RESET BINARY
        LOGS AND GTIDS
     </code>
    </a>
    .
   </p>
   <p>
    GTIDs are stored in the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table only when
    <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
     <code class="literal">
      gtid_mode
     </code>
    </a>
    is
    <code class="literal">
     ON
    </code>
    or
    <code class="literal">
     ON_PERMISSIVE
    </code>
    . If
        binary logging is disabled (
    <code class="literal">
     log_bin
    </code>
    is
    <code class="literal">
     OFF
    </code>
    ), or if
    <a class="link" href="replication-options-binary-log.html#sysvar_log_replica_updates">
     <code class="literal">
      log_replica_updates
     </code>
    </a>
    is
        disabled, the server stores the GTID belonging to each
        transaction together with the transaction in the buffer when the
        transaction is committed, and the background thread adds the
        contents of the buffer periodically as one or more entries to
        the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table. In addition,
        the table is compressed periodically at a user-configurable
        rate, as described in
    <a class="xref" href="replication-gtids-concepts.html#replication-gtids-gtid-executed-table-compression" title="mysql.gtid_executed Table Compression">
     mysql.gtid_executed Table Compression
    </a>
    .
   </p>
   <p>
    If binary logging is enabled (
    <code class="literal">
     log_bin
    </code>
    is
    <code class="literal">
     ON
    </code>
    ), for the
    <code class="literal">
     InnoDB
    </code>
    storage engine only, the server updates the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table in the same way as
        when binary logging or replica update logging is disabled,
        storing the GTID for each transaction at transaction commit
        time. For other storage engines, the server updates the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table only when the
        binary log is rotated or the server is shut down. At these
        times, the server writes GTIDs for all transactions that were
        written into the previous binary log into the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table.
   </p>
   <p>
    If the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table cannot be
        accessed for writes, and the binary log file is rotated for any
        reason other than reaching the maximum file size
        (
    <a class="link" href="replication-options-binary-log.html#sysvar_max_binlog_size">
     <code class="literal">
      max_binlog_size
     </code>
    </a>
    ), the current
        binary log file continues to be used. An error message is
        returned to the client that requested the rotation, and a
        warning is logged on the server. If the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table cannot be accessed
        for writes and
    <a class="link" href="replication-options-binary-log.html#sysvar_max_binlog_size">
     <code class="literal">
      max_binlog_size
     </code>
    </a>
    is reached, the server responds according to its
    <a class="link" href="replication-options-binary-log.html#sysvar_binlog_error_action">
     <code class="literal">
      binlog_error_action
     </code>
    </a>
    setting. If
    <code class="literal">
     IGNORE_ERROR
    </code>
    is set, an error is logged on
        the server and binary logging is halted, or if
    <code class="literal">
     ABORT_SERVER
    </code>
    is set, the server shuts down.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="replication-gtids-gtid-executed-table-compression">
       </a>
       mysql.gtid_executed Table Compression
      </h5>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045146309408">
   </a>
   <a class="indexterm" name="idm46045146307904">
   </a>
   <a class="indexterm" name="idm46045146306816">
   </a>
   <a class="indexterm" name="idm46045146305296">
   </a>
   <p>
    Over the course of time, the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table can become filled
        with many rows referring to individual GTIDs that originate on
        the same server, have the same GTID tag (if any), and whose
        transaction IDs make up a range, similar to what is shown here:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa85048720"><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 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 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> source_uuid                          <span class="token punctuation">|</span> interval_start <span class="token punctuation">|</span> interval_end <span class="token punctuation">|</span> gtid_tag <span class="token punctuation">|</span></span>
<span class="token operator">|</span><span class="token comment" spellcheck="true">--------------------------------------+----------------+--------------|----------+</span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 31             <span class="token punctuation">|</span> 31           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 32             <span class="token punctuation">|</span> 32           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 33             <span class="token punctuation">|</span> 33           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 34             <span class="token punctuation">|</span> 34           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 35             <span class="token punctuation">|</span> 35           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 36             <span class="token punctuation">|</span> 36           <span class="token punctuation">|</span> Domain_2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 37             <span class="token punctuation">|</span> 37           <span class="token punctuation">|</span> Domain_2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 38             <span class="token punctuation">|</span> 38           <span class="token punctuation">|</span> Domain_2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 39             <span class="token punctuation">|</span> 39           <span class="token punctuation">|</span> Domain_2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 40             <span class="token punctuation">|</span> 40           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 41             <span class="token punctuation">|</span> 41           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 42             <span class="token punctuation">|</span> 42           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 43             <span class="token punctuation">|</span> 43           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 44             <span class="token punctuation">|</span> 44           <span class="token punctuation">|</span> Domain_2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 45             <span class="token punctuation">|</span> 45           <span class="token punctuation">|</span> Domain_2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 46             <span class="token punctuation">|</span> 46           <span class="token punctuation">|</span> Domain_2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 47             <span class="token punctuation">|</span> 47           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3E11FA47<span class="token punctuation">-</span>71CA<span class="token punctuation">-</span>11E1<span class="token punctuation">-</span>9E33<span class="token punctuation">-</span>C80AA9429562 <span class="token punctuation">|</span> 48             <span class="token punctuation">|</span> 48           <span class="token punctuation">|</span> Domain_1 <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
   </div>
   <p>
    To save space, the MySQL server can compress the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table periodically by
        replacing each such set of rows with a single row that spans the
        entire interval of transaction identifiers, like this:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-none"><div class="docs-select-all right" id="sa75096154"><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">+--------------------------------------+----------------+--------------+----------+
| source_uuid                          | interval_start | interval_end | gtid_tag |
|--------------------------------------+----------------+--------------|----------+
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 31             | 35           | Domain_1 |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 36             | 39           | Domain_2 |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 40             | 43           | Domain_1 |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 44             | 46           | Domain_2 |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 47             | 48           | Domain_1 |
...</code></pre>
   </div>
   <p>
    The server can carry out compression using a dedicated
        foreground thread named
    <code class="literal">
     thread/sql/compress_gtid_table
    </code>
    . This thread
        is not listed in the output of
    <a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
     <code class="literal">
      SHOW
        PROCESSLIST
     </code>
    </a>
    , but it can be viewed as a row 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, as shown here:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa79690801"><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 operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>threads <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'%gtid%'</span>\G
<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> 1. row <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>
          THREAD_ID<span class="token punctuation">:</span> 26
               NAME<span class="token punctuation">:</span> thread/sql/compress_gtid_table
               TYPE<span class="token punctuation">:</span> FOREGROUND
     PROCESSLIST_ID<span class="token punctuation">:</span> 1
   PROCESSLIST_USER<span class="token punctuation">:</span> NULL
   PROCESSLIST_HOST<span class="token punctuation">:</span> NULL
     PROCESSLIST_DB<span class="token punctuation">:</span> NULL
PROCESSLIST_COMMAND<span class="token punctuation">:</span> Daemon
   PROCESSLIST_TIME<span class="token punctuation">:</span> 1509
  PROCESSLIST_STATE<span class="token punctuation">:</span> Suspending
   PROCESSLIST_INFO<span class="token punctuation">:</span> NULL
   PARENT_THREAD_ID<span class="token punctuation">:</span> 1
               ROLE<span class="token punctuation">:</span> NULL
       INSTRUMENTED<span class="token punctuation">:</span> YES
            HISTORY<span class="token punctuation">:</span> YES
    CONNECTION_TYPE<span class="token punctuation">:</span> NULL
       THREAD_OS_ID<span class="token punctuation">:</span> 18677</span></code></pre>
   </div>
   <p>
    When binary logging is enabled on the server, this compression
        method is not used, and instead the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table is compressed on
        each binary log rotation. However, when binary logging is
        disabled on the server, the
    <code class="literal">
     thread/sql/compress_gtid_table
    </code>
    thread sleeps
        until a specified number of transactions have been executed,
        then wakes up to perform compression of the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table. It then sleeps
        until the same number of transactions have taken place, then
        wakes up to perform the compression again, repeating this loop
        indefinitely. The number of transactions that elapse before the
        table is compressed, and thus the compression rate, is
        controlled by the value of the
    <a class="link" href="replication-options-gtids.html#sysvar_gtid_executed_compression_period">
     <code class="literal">
      gtid_executed_compression_period
     </code>
    </a>
    system variable. Setting that value to 0 means that the thread
        never wakes up, meaning that this explicit compression method is
        not used. Instead, compression occurs implicitly as required.
   </p>
   <p>
    <a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
     <code class="literal">
      InnoDB
     </code>
    </a>
    transactions are written to
        the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table by a process
        separate from that used for transactions involving storage
        engines other than
    <code class="literal">
     InnoDB
    </code>
    . This process is
        controlled by a different thread,
    <code class="literal">
     innodb/clone_gtid_thread
    </code>
    . This GTID persister
        thread collects GTIDs in groups, flushes them to the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table, then compresses
        the table. If the server has a mix of
    <a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
     <code class="literal">
      InnoDB
     </code>
    </a>
    transactions and
        non-
    <a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
     <code class="literal">
      InnoDB
     </code>
    </a>
    transactions, which are
        written to the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table
        individually, the compression carried out by the
    <code class="literal">
     compress_gtid_table
    </code>
    thread interferes with
        the work of the GTID persister thread and can slow it
        significantly. For this reason, it is recommended that you set
    <a class="link" href="replication-options-gtids.html#sysvar_gtid_executed_compression_period">
     <code class="literal">
      gtid_executed_compression_period
     </code>
    </a>
    to 0, so that the
    <code class="literal">
     compress_gtid_table
    </code>
    thread
        is never activated.
   </p>
   <p>
    The default value for
    <a class="link" href="replication-options-gtids.html#sysvar_gtid_executed_compression_period">
     <code class="literal">
      gtid_executed_compression_period
     </code>
    </a>
    is 0, and all transactions regardless of storage engine are
        written to the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table by
        the GTID persister thread.
   </p>
   <p>
    When a server instance is started, if
    <a class="link" href="replication-options-gtids.html#sysvar_gtid_executed_compression_period">
     <code class="literal">
      gtid_executed_compression_period
     </code>
    </a>
    is set to a nonzero value and the
    <code class="literal">
     thread/sql/compress_gtid_table
    </code>
    thread is
        launched, in most server configurations, explicit compression is
        performed for the
    <code class="literal">
     mysql.gtid_executed
    </code>
    table.
        Compression is triggered by the thread launch.
   </p>
  </div>
 </div>
 <br/>
</div>
