Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 35.1Mb
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  / ...  / Optimization  / Optimizing for InnoDB Tables  /  Optimizing InnoDB DDL Operations

8.5.7 Optimizing InnoDB DDL Operations

  • Many DDL operations on tables and indexes (CREATE,ALTER, andDROP statements) can be performed online. SeeSection 14.13, “InnoDB and Online DDL” for details.

  • Online DDL support for adding secondary indexes means that you can generally speed up the process of creating and loading a table and associated indexes by creating the table without secondary indexes, then adding secondary indexes after the data is loaded.

  • UseTRUNCATE TABLE to empty a table, notDELETE FROMtbl_name. Foreign key constraints can make aTRUNCATE statement work like a regularDELETE statement, in which case a sequence of commands likeDROP TABLE andCREATE TABLE might be fastest.

  • Because the primary key is integral to the storage layout of eachInnoDB table, and changing the definition of the primary key involves reorganizing the whole table, always set up the primary key as part of theCREATE TABLE statement, and plan ahead so that you do not need toALTER orDROP the primary key afterward.