Skip to main content
Version: V1.4.1

Online and offline DDL operations

Online DDL allows applications to continue accessing a table while its schema is being changed. Offline DDL reorganizes data or holds an exclusive lock, blocking reads and writes to the table while the operation is in progress. Whether a DDL operation must reorganize data can also depend on the table schema, index type, partitioning method, and whether multiple operations are combined in one statement.

Common online DDL operations​

The following operations usually change only metadata or can be completed online:

CategoryOperationDescription
IndexAdd, drop, or rename an indexThe time required to add an index depends on the amount of data. Reads and writes remain available while the operation is in progress.
IndexAdd, drop, or rename indexes in the same statementThe total duration is determined by the slowest operation.
ColumnAdd a column at the end of a tableChanges metadata only.
ColumnAdd a virtual generated columnChanges metadata only.
ColumnChange a column default or NULL attributeWhether existing data must be validated depends on the specific change.
ColumnRename a columnChanges metadata only. Application SQL must be updated to use the new column name.
TableRename a table, or change its row format, block size, compression method, or parallelismPrimarily changes table metadata.
PartitionAdd a Range or List partitionChanges partition metadata only.

Common offline DDL operations​

The following operations usually reorganize data or hold a table lock for an extended period. Schedule a maintenance window for them:

CategoryOperationDescription
ColumnReorder columnsRewrites existing data.
ColumnAdd or modify an auto-increment columnReorganizes or validates existing data.
ColumnChange a column data typeConverts and rewrites existing data.
ColumnAdd or drop a primary keyReorganizes data.
ColumnAdd or drop a stored generated columnReorganizes data.
ColumnDrop a columnReorganizes data.
TableConvert the character set or collationConverts and rewrites character data.
TableRun TRUNCATE TABLE or DROP TABLEThe duration depends on active transactions and metadata locks.
PartitionChange the partitioning schemeReorganizes partition data.
PartitionDrop, truncate, or exchange a partitionHolds a partition-level or table-level metadata lock.

Recommendations​

  • Test the DDL operation in an environment with a production-like schema and data volume, and record its duration, lock waits, and additional disk usage.
  • When combining multiple DDL operations, treat the entire statement as offline if any operation requires data reorganization.
  • Before execution, make sure that no long-running transaction is using the target table. During execution, use SHOW PROCESSLIST to monitor waits.
  • Before running a DDL operation that might reorganize a large table, reserve sufficient disk space and schedule a maintenance window.
  • The ALGORITHM and LOCK clauses are supported only for MySQL syntax compatibility. Do not use them to determine whether seekdb will execute a DDL operation online.