Loading Docs/manual.texi +24 −8 Original line number Diff line number Diff line Loading @@ -19115,6 +19115,8 @@ alter_specification: or DROP [COLUMN] col_name or DROP PRIMARY KEY or DROP INDEX index_name or DISABLE KEYS or ENABLE KEYS or RENAME [TO] new_tbl_name or ORDER BY col or table_options Loading Loading @@ -19276,6 +19278,15 @@ If you use @code{ALTER TABLE} on a @code{MyISAM} table, all non-unique indexes are created in a separate batch (like in @code{REPAIR}). This should make @code{ALTER TABLE} much faster when you have many indexes. @item Since @strong{MySQL 4.0} this feature could be activated explicitly. @code{ALTER TABLE ... DISABLE KEYS} makes @strong{MySQL} to stop updating non-unique indexes for @code{MyISAM} table. @code{ALTER TABLE ... ENABLE KEYS} then should be used to recreate missing indexes. As @strong{MySQL} does it with special algorithm which is much faster then inserting keys one by one, disabling keys could give a considerable speedup on bulk inserts. @item @findex mysql_info() With the C API function @code{mysql_info()}, you can find out how many Loading Loading @@ -24758,14 +24769,11 @@ InnoDB: Database physically writes the file full: wait... InnoDB: Data file /home/heikki/data/ibdata2 did not exist: new to be created InnoDB: Setting file /home/heikki/data/ibdata2 size to 262144000 InnoDB: Database physically writes the file full: wait... InnoDB: Log file /home/heikki/data/logs/ib_logfile0 did not exist: new to be c reated InnoDB: Log file /home/heikki/data/logs/ib_logfile0 did not exist: new to be created InnoDB: Setting log file /home/heikki/data/logs/ib_logfile0 size to 5242880 InnoDB: Log file /home/heikki/data/logs/ib_logfile1 did not exist: new to be c reated InnoDB: Log file /home/heikki/data/logs/ib_logfile1 did not exist: new to be created InnoDB: Setting log file /home/heikki/data/logs/ib_logfile1 size to 5242880 InnoDB: Log file /home/heikki/data/logs/ib_logfile2 did not exist: new to be c reated InnoDB: Log file /home/heikki/data/logs/ib_logfile2 did not exist: new to be created InnoDB: Setting log file /home/heikki/data/logs/ib_logfile2 size to 5242880 InnoDB: Started mysqld: ready for connections Loading Loading @@ -31050,8 +31058,13 @@ Execute a @code{FLUSH TABLES} statement or the shell command @code{mysqladmin flush-tables}. @end enumerate This procedure will be built into @code{LOAD DATA INFILE} in some future version of @strong{MySQL}. Since @strong{MySQL 4.0} you can also use @code{ALTER TABLE tbl_name DISABLE KEYS} instead of @code{myisamchk --keys-used=0 -rq /path/to/db/tbl_name} and @code{ALTER TABLE tbl_name ENABLE KEYS} instead of @code{myisamchk -r -q /path/to/db/tbl_name}. This way you can also skip @code{FLUSH TABLES} steps. @item You can speed up insertions by locking your tables: Loading Loading @@ -44082,6 +44095,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. @itemize @bullet @item Added @code{ALTER TABLE table_name DISABLE KEYS} and @code{ALTER TABLE table_name ENABLE KEYS} commands. @item Added @code{HANDLER} command. @item Added @code{SQL_CALC_FOUND_ROWS} and @code{FOUND_ROWS()}. This make it merge/open.c +7 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ int mode; int handle_locking; { int save_errno,i,errpos; uint files,dir_length,length; uint files,dir_length,length, options; ulonglong file_offset; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; MRG_INFO info,*m_info; Loading Loading @@ -90,16 +90,22 @@ int handle_locking; m_info->open_tables=(MRG_TABLE *) (m_info+1); m_info->tables=files; options= (uint) ~0; for (i=files ; i-- > 0 ; ) { m_info->open_tables[i].table=isam; m_info->options|=isam->s->base.options; options&=isam->s->base.options; m_info->records+=isam->s->state.records; m_info->del+=isam->s->state.del; m_info->data_file_length=isam->s->state.data_file_length; if (i) isam=(N_INFO*) (isam->open_list.next->data); } /* Don't force readonly if not all tables are readonly */ if (! (options & (HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA))) m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA); /* Fix fileinfo for easyer debugging (actually set by rrnd) */ file_offset=0; for (i=0 ; (uint) i < files ; i++) Loading myisammrg/myrg_open.c +7 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ int mode; int handle_locking; { int save_errno,i,errpos; uint files,dir_length,length; uint files,dir_length,length,options; ulonglong file_offset; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; MYRG_INFO info,*m_info; Loading Loading @@ -93,16 +93,22 @@ int handle_locking; m_info->tables=files; errpos=2; options= (uint) ~0; for (i=files ; i-- > 0 ; ) { m_info->open_tables[i].table=isam; m_info->options|=isam->s->options; options&=isam->s->options; m_info->records+=isam->state->records; m_info->del+=isam->state->del; m_info->data_file_length+=isam->state->data_file_length; if (i) isam=(MI_INFO*) (isam->open_list.next->data); } /* Don't force readonly if not all tables are readonly */ if (! (options & (HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA))) m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA); /* Fix fileinfo for easyer debugging (actually set by rrnd) */ file_offset=0; for (i=0 ; (uint) i < files ; i++) Loading mysql-test/t/alter_table.test +20 −0 Original line number Diff line number Diff line Loading @@ -71,3 +71,23 @@ ALTER TABLE t1 ADD Column new_col int not null; UNLOCK TABLES; OPTIMIZE TABLE t1; DROP TABLE t1; drop table if exists t1; # # ALTER TABLE ... ENABLE/DISABLE KEYS create table t1 (n1 int not null, n2 int, n3 int, n4 float, unique(n1), key (n1, n2, n3, n4), key (n2, n3, n4, n1), key (n3, n4, n1, n2), key (n4, n1, n2, n3) ); alter table t1 disable keys; let $1=10000; while ($1) { eval insert into t1 values($1,RAND()*1000,RAND()*1000,RAND()); dec $1; } alter table t1 enable keys; drop table t1; sql/lex.h +2 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ static SYMBOL symbols[] = { { "DELETE", SYM(DELETE_SYM),0,0}, { "DESC", SYM(DESC),0,0}, { "DESCRIBE", SYM(DESCRIBE),0,0}, { "DISABLE", SYM(DISABLE_SYM),0,0}, { "DISTINCT", SYM(DISTINCT),0,0}, { "DISTINCTROW", SYM(DISTINCT),0,0}, /* Access likes this */ { "DOUBLE", SYM(DOUBLE_SYM),0,0}, Loading @@ -123,6 +124,7 @@ static SYMBOL symbols[] = { { "ELSE", SYM(ELSE),0,0}, { "ESCAPE", SYM(ESCAPE_SYM),0,0}, { "ESCAPED", SYM(ESCAPED),0,0}, { "ENABLE", SYM(ENABLE_SYM),0,0}, { "ENCLOSED", SYM(ENCLOSED),0,0}, { "ENUM", SYM(ENUM),0,0}, { "EXPLAIN", SYM(DESCRIBE),0,0}, Loading Loading
Docs/manual.texi +24 −8 Original line number Diff line number Diff line Loading @@ -19115,6 +19115,8 @@ alter_specification: or DROP [COLUMN] col_name or DROP PRIMARY KEY or DROP INDEX index_name or DISABLE KEYS or ENABLE KEYS or RENAME [TO] new_tbl_name or ORDER BY col or table_options Loading Loading @@ -19276,6 +19278,15 @@ If you use @code{ALTER TABLE} on a @code{MyISAM} table, all non-unique indexes are created in a separate batch (like in @code{REPAIR}). This should make @code{ALTER TABLE} much faster when you have many indexes. @item Since @strong{MySQL 4.0} this feature could be activated explicitly. @code{ALTER TABLE ... DISABLE KEYS} makes @strong{MySQL} to stop updating non-unique indexes for @code{MyISAM} table. @code{ALTER TABLE ... ENABLE KEYS} then should be used to recreate missing indexes. As @strong{MySQL} does it with special algorithm which is much faster then inserting keys one by one, disabling keys could give a considerable speedup on bulk inserts. @item @findex mysql_info() With the C API function @code{mysql_info()}, you can find out how many Loading Loading @@ -24758,14 +24769,11 @@ InnoDB: Database physically writes the file full: wait... InnoDB: Data file /home/heikki/data/ibdata2 did not exist: new to be created InnoDB: Setting file /home/heikki/data/ibdata2 size to 262144000 InnoDB: Database physically writes the file full: wait... InnoDB: Log file /home/heikki/data/logs/ib_logfile0 did not exist: new to be c reated InnoDB: Log file /home/heikki/data/logs/ib_logfile0 did not exist: new to be created InnoDB: Setting log file /home/heikki/data/logs/ib_logfile0 size to 5242880 InnoDB: Log file /home/heikki/data/logs/ib_logfile1 did not exist: new to be c reated InnoDB: Log file /home/heikki/data/logs/ib_logfile1 did not exist: new to be created InnoDB: Setting log file /home/heikki/data/logs/ib_logfile1 size to 5242880 InnoDB: Log file /home/heikki/data/logs/ib_logfile2 did not exist: new to be c reated InnoDB: Log file /home/heikki/data/logs/ib_logfile2 did not exist: new to be created InnoDB: Setting log file /home/heikki/data/logs/ib_logfile2 size to 5242880 InnoDB: Started mysqld: ready for connections Loading Loading @@ -31050,8 +31058,13 @@ Execute a @code{FLUSH TABLES} statement or the shell command @code{mysqladmin flush-tables}. @end enumerate This procedure will be built into @code{LOAD DATA INFILE} in some future version of @strong{MySQL}. Since @strong{MySQL 4.0} you can also use @code{ALTER TABLE tbl_name DISABLE KEYS} instead of @code{myisamchk --keys-used=0 -rq /path/to/db/tbl_name} and @code{ALTER TABLE tbl_name ENABLE KEYS} instead of @code{myisamchk -r -q /path/to/db/tbl_name}. This way you can also skip @code{FLUSH TABLES} steps. @item You can speed up insertions by locking your tables: Loading Loading @@ -44082,6 +44095,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. @itemize @bullet @item Added @code{ALTER TABLE table_name DISABLE KEYS} and @code{ALTER TABLE table_name ENABLE KEYS} commands. @item Added @code{HANDLER} command. @item Added @code{SQL_CALC_FOUND_ROWS} and @code{FOUND_ROWS()}. This make it
merge/open.c +7 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ int mode; int handle_locking; { int save_errno,i,errpos; uint files,dir_length,length; uint files,dir_length,length, options; ulonglong file_offset; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; MRG_INFO info,*m_info; Loading Loading @@ -90,16 +90,22 @@ int handle_locking; m_info->open_tables=(MRG_TABLE *) (m_info+1); m_info->tables=files; options= (uint) ~0; for (i=files ; i-- > 0 ; ) { m_info->open_tables[i].table=isam; m_info->options|=isam->s->base.options; options&=isam->s->base.options; m_info->records+=isam->s->state.records; m_info->del+=isam->s->state.del; m_info->data_file_length=isam->s->state.data_file_length; if (i) isam=(N_INFO*) (isam->open_list.next->data); } /* Don't force readonly if not all tables are readonly */ if (! (options & (HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA))) m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA); /* Fix fileinfo for easyer debugging (actually set by rrnd) */ file_offset=0; for (i=0 ; (uint) i < files ; i++) Loading
myisammrg/myrg_open.c +7 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ int mode; int handle_locking; { int save_errno,i,errpos; uint files,dir_length,length; uint files,dir_length,length,options; ulonglong file_offset; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; MYRG_INFO info,*m_info; Loading Loading @@ -93,16 +93,22 @@ int handle_locking; m_info->tables=files; errpos=2; options= (uint) ~0; for (i=files ; i-- > 0 ; ) { m_info->open_tables[i].table=isam; m_info->options|=isam->s->options; options&=isam->s->options; m_info->records+=isam->state->records; m_info->del+=isam->state->del; m_info->data_file_length+=isam->state->data_file_length; if (i) isam=(MI_INFO*) (isam->open_list.next->data); } /* Don't force readonly if not all tables are readonly */ if (! (options & (HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA))) m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA); /* Fix fileinfo for easyer debugging (actually set by rrnd) */ file_offset=0; for (i=0 ; (uint) i < files ; i++) Loading
mysql-test/t/alter_table.test +20 −0 Original line number Diff line number Diff line Loading @@ -71,3 +71,23 @@ ALTER TABLE t1 ADD Column new_col int not null; UNLOCK TABLES; OPTIMIZE TABLE t1; DROP TABLE t1; drop table if exists t1; # # ALTER TABLE ... ENABLE/DISABLE KEYS create table t1 (n1 int not null, n2 int, n3 int, n4 float, unique(n1), key (n1, n2, n3, n4), key (n2, n3, n4, n1), key (n3, n4, n1, n2), key (n4, n1, n2, n3) ); alter table t1 disable keys; let $1=10000; while ($1) { eval insert into t1 values($1,RAND()*1000,RAND()*1000,RAND()); dec $1; } alter table t1 enable keys; drop table t1;
sql/lex.h +2 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ static SYMBOL symbols[] = { { "DELETE", SYM(DELETE_SYM),0,0}, { "DESC", SYM(DESC),0,0}, { "DESCRIBE", SYM(DESCRIBE),0,0}, { "DISABLE", SYM(DISABLE_SYM),0,0}, { "DISTINCT", SYM(DISTINCT),0,0}, { "DISTINCTROW", SYM(DISTINCT),0,0}, /* Access likes this */ { "DOUBLE", SYM(DOUBLE_SYM),0,0}, Loading @@ -123,6 +124,7 @@ static SYMBOL symbols[] = { { "ELSE", SYM(ELSE),0,0}, { "ESCAPE", SYM(ESCAPE_SYM),0,0}, { "ESCAPED", SYM(ESCAPED),0,0}, { "ENABLE", SYM(ENABLE_SYM),0,0}, { "ENCLOSED", SYM(ENCLOSED),0,0}, { "ENUM", SYM(ENUM),0,0}, { "EXPLAIN", SYM(DESCRIBE),0,0}, Loading