Documentation Home
MySQL 9.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 41.2Mb
PDF (A4) - 41.3Mb
Man Pages (TGZ) - 262.8Kb
Man Pages (Zip) - 368.8Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


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

10.5.7 Optimizing InnoDB DDL Operations

  • Many DDL operations on tables and indexes (CREATE,ALTER, andDROP statements) can be performed online. SeeSection 17.12, “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.