From b42eff16cb6ff402d5b7d332f7081df3948a1559 Mon Sep 17 00:00:00 2001 From: "serg@serg.mysql.com" <> Date: Sat, 7 Dec 2002 22:40:20 +0100 Subject: bulk insert code optimized --- sql/ha_myisam.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'sql/ha_myisam.cc') diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 0c472ea6a45..0560afdf068 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -685,11 +685,14 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows) /* Only disable old index if the table was empty */ if (file->state->records == 0) mi_disable_non_unique_index(file,rows); - ha_myisam::extra_opt(HA_EXTRA_BULK_INSERT_BEGIN, - current_thd->variables.bulk_insert_buff_size); + else + { + mi_init_bulk_insert(file, + current_thd->variables.bulk_insert_buff_size, rows); table->bulk_insert= 1; } } + } enable_activate_all_index=1; } else @@ -704,7 +707,7 @@ bool ha_myisam::activate_all_index(THD *thd) MYISAM_SHARE* share = file->s; DBUG_ENTER("activate_all_index"); - mi_extra(file, HA_EXTRA_BULK_INSERT_END, 0); + mi_end_bulk_insert(file); table->bulk_insert= 0; if (enable_activate_all_index && share->state.key_map != set_bits(ulonglong, share->base.keys)) @@ -945,13 +948,11 @@ int ha_myisam::extra(enum ha_extra_function operation) } -/* To be used with WRITE_CACHE, EXTRA_CACHE and BULK_INSERT_BEGIN */ +/* To be used with WRITE_CACHE and EXTRA_CACHE */ int ha_myisam::extra_opt(enum ha_extra_function operation, ulong cache_size) { - if ((specialflag & SPECIAL_SAFE_MODE) & - (operation == HA_EXTRA_WRITE_CACHE || - operation == HA_EXTRA_BULK_INSERT_BEGIN)) + if ((specialflag & SPECIAL_SAFE_MODE) & operation == HA_EXTRA_WRITE_CACHE) return 0; return mi_extra(file, operation, (void*) &cache_size); } @@ -1213,8 +1214,7 @@ longlong ha_myisam::get_auto_increment() } if (table->bulk_insert) - mi_extra(file, HA_EXTRA_BULK_INSERT_FLUSH, - (void*) &table->next_number_index); + mi_flush_bulk_insert(file, table->next_number_index); longlong nr; int error; -- cgit v1.2.1 From 62dfd57475826002b8fa1bed24d563363a1faf84 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Thu, 12 Dec 2002 21:01:32 +0200 Subject: Removed compiler warnings Fixed wrong variable name for Windows --- sql/ha_myisam.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/ha_myisam.cc') diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 0560afdf068..fcef1284385 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -628,7 +628,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) the following 'if', thought conceptually wrong, is a useful optimization nevertheless. */ - if (file->state != &file->s->state.state); + if (file->state != &file->s->state.state) file->s->state.state = *file->state; if (file->s->base.auto_key) update_auto_increment_key(¶m, file, 1); @@ -952,7 +952,7 @@ int ha_myisam::extra(enum ha_extra_function operation) int ha_myisam::extra_opt(enum ha_extra_function operation, ulong cache_size) { - if ((specialflag & SPECIAL_SAFE_MODE) & operation == HA_EXTRA_WRITE_CACHE) + if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_WRITE_CACHE) return 0; return mi_extra(file, operation, (void*) &cache_size); } -- cgit v1.2.1 From 9c509fcb52e9b8d8342374370708912ab6e8b282 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Sat, 14 Dec 2002 12:45:31 +0200 Subject: Transactions in AUTOCOMMIT=0 mode didn't rotate binary log Don't enable any bulk insert or record caching code if inserting less than MIN_ROWS_TO_USE_BULK_INSERT rows (100) --- sql/ha_myisam.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'sql/ha_myisam.cc') diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index fcef1284385..797fe97ea74 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -682,17 +682,24 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows) mi_extra(file, HA_EXTRA_NO_KEYS, 0); else { - /* Only disable old index if the table was empty */ - if (file->state->records == 0) + /* + Only disable old index if the table was empty and we are inserting + a lot of rows. + We should not do this for only a few rows as this is slower and + we don't want to update the key statistics based of only a few rows. + */ + if (file->state->records == 0 && + rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT) mi_disable_non_unique_index(file,rows); else { mi_init_bulk_insert(file, - current_thd->variables.bulk_insert_buff_size, rows); - table->bulk_insert= 1; + current_thd->variables.bulk_insert_buff_size, + rows); + table->bulk_insert= 1; + } } } - } enable_activate_all_index=1; } else -- cgit v1.2.1 From 43875f50cbc4dcdb3a870d64d1f78a4467f36517 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Mon, 16 Dec 2002 17:28:53 +0200 Subject: Use delayed create index for LOAD DATA INFILE, INSERT ... SELECT and CREATE ... SELECT (Accidently disabled by a recent push) --- sql/ha_myisam.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/ha_myisam.cc') diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 797fe97ea74..0a419879e3a 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -689,7 +689,7 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows) we don't want to update the key statistics based of only a few rows. */ if (file->state->records == 0 && - rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT) + (!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT)) mi_disable_non_unique_index(file,rows); else { -- cgit v1.2.1