public override void RebuildIndexes(List <TableInfo> tables) { using (DataManager dm = DataManager.Create(DataConnectionSpec)) { DataConnectionSpec dsc = DataConnectionSpec.Clone(dm); // MySQL creates indexes orders of magnitude faster (in InnoDB engine at least) // if we issue a single ALTER TABLE statement with multiple indexes on it. ProcessTables(tables, ti => { if (ti.IsSelected) { string toRun = null; try { toRun = ((MySqlTableInfo)ti).GenerateRebuildAllIndexesForTable(); showProgress(getDisplayMember("RebuildIndexes{progress}", "Rebuilding all indexes for {0}...", ti.TableName), 0, 0); dm.DataConnectionSpec.CommandTimeout = 3600; // allow one hour for each table index recreation (!!!) if (!String.IsNullOrEmpty(toRun)) { dm.Write(toRun); } } catch (Exception ex) { throw new InvalidOperationException(ex.Message + ". SQL=" + toRun, ex); } } }); } }
public override void CreateConstraints(List <TableInfo> tables, bool createForeignConstraints, bool createSelfReferentialConstraints) { using (DataManager dm = DataManager.Create(DataConnectionSpec)) { DataConnectionSpec dsc = DataConnectionSpec.Clone(dm); // MySQL creates constraints orders of magnitude faster (in InnoDB engine at least) // if we issue a single ALTER TABLE statement with multiple constraints on it. ProcessTables(tables, ti => { if (ti.IsSelected) { string toRun = ((MySqlTableInfo)ti).GenerateCreateAllConstraintsForTable(createForeignConstraints, createSelfReferentialConstraints); showProgress(getDisplayMember("CreateConstraints{progress}", "Creating all constraints for {0}...", ti.TableName), 0, 0); dm.DataConnectionSpec.CommandTimeout = 3600; // allow one hour for each table index recreation (!!!) if (!String.IsNullOrEmpty(toRun)) { dm.Write(toRun); } } }); } }