summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2002-12-07 22:40:20 +0100
committerunknown <serg@serg.mysql.com>2002-12-07 22:40:20 +0100
commit6271ea35b83501781cf3ee51a62fd95870b3fb96 (patch)
treecac4edcace5032716391947982c07af2dba77b24 /sql
parent23865c0eea7d3d670f4b84a76cbe3511fe241b7f (diff)
downloadmariadb-git-6271ea35b83501781cf3ee51a62fd95870b3fb96.tar.gz
bulk insert code optimized
mysql-test/r/distinct.result: updated mysql-test/r/fulltext.result: updated mysql-test/r/select.result: updated mysql-test/r/show_check.result: updated mysql-test/t/insert.test: updated
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_myisam.cc18
-rw-r--r--sql/ha_myisammrg.cc4
-rw-r--r--sql/sql_insert.cc20
3 files changed, 17 insertions, 25 deletions
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;
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index 07683dca73e..f2c3d1a7747 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -247,9 +247,7 @@ int ha_myisammrg::extra(enum ha_extra_function operation)
int ha_myisammrg::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 myrg_extra(file, operation, (void*) &cache_size);
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 5ca08aa31b0..4d1b2e59f60 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -105,7 +105,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
int error;
bool log_on= ((thd->options & OPTION_UPDATE_LOG) ||
!(thd->master_access & SUPER_ACL));
- bool transactional_table, log_delayed, bulk_insert=0;
+ bool transactional_table, log_delayed, bulk_insert;
uint value_count;
ulong counter = 1;
ulonglong id;
@@ -187,21 +187,16 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
thd->proc_info="update";
if (duplic == DUP_IGNORE || duplic == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
- if ((bulk_insert= (values_list.elements >= MIN_ROWS_TO_USE_BULK_INSERT &&
- lock_type != TL_WRITE_DELAYED &&
- !(specialflag & SPECIAL_SAFE_MODE))))
+ if ((lock_type != TL_WRITE_DELAYED && !(specialflag & SPECIAL_SAFE_MODE)))
{
table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
min(thd->variables.read_buff_size,
table->avg_row_length*values_list.elements));
- if (thd->variables.bulk_insert_buff_size)
- table->file->extra_opt(HA_EXTRA_BULK_INSERT_BEGIN,
- min(thd->variables.bulk_insert_buff_size,
- (table->total_key_length +
- table->keys * TREE_ELEMENT_EXTRA_SIZE)*
- values_list.elements));
- table->bulk_insert= 1;
+ table->file->deactivate_non_unique_index(values_list.elements);
+ bulk_insert=1;
}
+ else
+ bulk_insert=0;
while ((values= its++))
{
@@ -278,7 +273,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
error=1;
}
}
- if (table->file->extra(HA_EXTRA_BULK_INSERT_END))
+ if (table->file->activate_all_index(thd))
{
if (!error)
{
@@ -286,7 +281,6 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
error=1;
}
}
- table->bulk_insert= 0;
}
if (id && values_list.elements != 1)
thd->insert_id(id); // For update log