<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="innodb-online-ddl-space-requirements">
      </a>
      17.12.3 Online DDL Space Requirements
     </h3>
    </div>
   </div>
  </div>
  <p>
   Disk space requirements for online DDL operations are outlined
      below. The requirements do not apply to operations that are
      performed instantly.
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Temporary log files:
     </p>
     <p>
      A temporary log file records concurrent DML when an online DDL
          operation creates an index or alters a table. The temporary
          log file is extended as required by the value of
      <a class="link" href="innodb-parameters.html#sysvar_innodb_sort_buffer_size">
       <code class="literal">
        innodb_sort_buffer_size
       </code>
      </a>
      up to
          a maximum specified by
      <a class="link" href="innodb-parameters.html#sysvar_innodb_online_alter_log_max_size">
       <code class="literal">
        innodb_online_alter_log_max_size
       </code>
      </a>
      .
          If the operation takes a long time and concurrent DML modifies
          the table so much that the size of the temporary log file
          exceeds the value of
      <a class="link" href="innodb-parameters.html#sysvar_innodb_online_alter_log_max_size">
       <code class="literal">
        innodb_online_alter_log_max_size
       </code>
      </a>
      ,
          the online DDL operation fails with a
      <code class="literal">
       DB_ONLINE_LOG_TOO_BIG
      </code>
      error, and
          uncommitted concurrent DML operations are rolled back. A large
      <a class="link" href="innodb-parameters.html#sysvar_innodb_online_alter_log_max_size">
       <code class="literal">
        innodb_online_alter_log_max_size
       </code>
      </a>
      setting permits more DML during an online DDL operation, but
          it also extends the period of time at the end of the DDL
          operation when the table is locked to apply logged DML.
     </p>
     <p>
      The
      <a class="link" href="innodb-parameters.html#sysvar_innodb_sort_buffer_size">
       <code class="literal">
        innodb_sort_buffer_size
       </code>
      </a>
      variable also defines the size of the temporary log file read
          buffer and write buffer.
     </p>
    </li>
    <li class="listitem">
     <p>
      Temporary sort files:
     </p>
     <p>
      Online DDL operations that rebuild the table write temporary
          sort files to the MySQL temporary directory
          (
      <code class="literal">
       $TMPDIR
      </code>
      on Unix,
      <code class="literal">
       %TEMP%
      </code>
      on Windows, or the directory specified by
      <a class="link" href="server-system-variables.html#sysvar_tmpdir">
       <code class="literal">
        --tmpdir
       </code>
      </a>
      ) during index
          creation. Temporary sort files are not created in the
          directory that contains the original table. Each temporary
          sort file is large enough to hold one column of data, and each
          sort file is removed when its data is merged into the final
          table or index. Operations involving temporary sort files may
          require temporary space equal to the amount of data in the
          table plus indexes. An error is reported if online DDL
          operation uses all of the available disk space on the file
          system where the data directory resides.
     </p>
     <p>
      If the MySQL temporary directory is not large enough to hold
          the sort files, set
      <a class="link" href="server-system-variables.html#sysvar_tmpdir">
       <code class="literal">
        tmpdir
       </code>
      </a>
      to
          a different directory. Alternatively, define a separate
          temporary directory for online DDL operations using
      <a class="link" href="innodb-parameters.html#sysvar_innodb_tmpdir">
       <code class="literal">
        innodb_tmpdir
       </code>
      </a>
      . This option
          was introduced to help avoid temporary directory overflows
          that could occur as a result of large temporary sort files.
     </p>
    </li>
    <li class="listitem">
     <p>
      Intermediate table files:
     </p>
     <p>
      Some online DDL operations that rebuild the table create a
          temporary intermediate table file in the same directory as the
          original table. An intermediate table file may require space
          equal to the size of the original table. Intermediate table
          file names begin with
      <code class="filename">
       #sql-ib
      </code>
      prefix and
          only appear briefly during the online DDL operation.
     </p>
     <p>
      The
      <a class="link" href="innodb-parameters.html#sysvar_innodb_tmpdir">
       <code class="literal">
        innodb_tmpdir
       </code>
      </a>
      option is
          not applicable to intermediate table files.
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
