Commit 5e3b01ef authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1858

remove auto increment overhead on bulk loads

git-svn-id: file:///svn/mysql/tokudb-engine/src@13202 c7de825b-a66e-492c-adef-691d508d4ae1
parent d37da476
...@@ -869,6 +869,8 @@ ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg):handler(hton, t ...@@ -869,6 +869,8 @@ ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg):handler(hton, t
num_updated_rows_in_stmt = 0; num_updated_rows_in_stmt = 0;
blob_buff = NULL; blob_buff = NULL;
num_blob_bytes = 0; num_blob_bytes = 0;
delay_auto_inc_update = false;
auto_inc_update_req = false;
} }
// //
...@@ -2349,6 +2351,28 @@ bool ha_tokudb::check_if_incompatible_data(HA_CREATE_INFO * info, uint table_cha ...@@ -2349,6 +2351,28 @@ bool ha_tokudb::check_if_incompatible_data(HA_CREATE_INFO * info, uint table_cha
return COMPATIBLE_DATA_YES; return COMPATIBLE_DATA_YES;
} }
void ha_tokudb::start_bulk_insert(ha_rows rows) {
//
// make sure delay_auto_inc_update is true
//
delay_auto_inc_update = true;
auto_inc_update_req = false;
}
int ha_tokudb::end_bulk_insert() {
int error = 0;
if (auto_inc_update_req) {
pthread_mutex_lock(&share->mutex);
error = update_max_auto_inc(share->status_block, share->last_auto_increment);
pthread_mutex_unlock(&share->mutex);
}
delay_auto_inc_update = false;
auto_inc_update_req = false;
return error;
}
// //
// Stores a row in the table, called when handling an INSERT query // Stores a row in the table, called when handling an INSERT query
// Parameters: // Parameters:
...@@ -2403,9 +2427,12 @@ int ha_tokudb::write_row(uchar * record) { ...@@ -2403,9 +2427,12 @@ int ha_tokudb::write_row(uchar * record) {
record record
); );
if (curr_auto_inc > share->last_auto_increment) { if (curr_auto_inc > share->last_auto_increment) {
error = update_max_auto_inc(share->status_block, curr_auto_inc);
if (!error) {
share->last_auto_increment = curr_auto_inc; share->last_auto_increment = curr_auto_inc;
if (delay_auto_inc_update) {
auto_inc_update_req = true;
}
else {
update_max_auto_inc(share->status_block, share->last_auto_increment);
} }
} }
pthread_mutex_unlock(&share->mutex); pthread_mutex_unlock(&share->mutex);
...@@ -5100,8 +5127,13 @@ void ha_tokudb::get_auto_increment(ulonglong offset, ulonglong increment, ulongl ...@@ -5100,8 +5127,13 @@ void ha_tokudb::get_auto_increment(ulonglong offset, ulonglong increment, ulongl
else { else {
nr = share->last_auto_increment + increment; nr = share->last_auto_increment + increment;
} }
update_max_auto_inc(share->status_block, nr + (nb_desired_values - 1)*increment);
share->last_auto_increment = nr + (nb_desired_values - 1)*increment; share->last_auto_increment = nr + (nb_desired_values - 1)*increment;
if (delay_auto_inc_update) {
auto_inc_update_req = true;
}
else {
update_max_auto_inc(share->status_block, share->last_auto_increment);
}
if (tokudb_debug & TOKUDB_DEBUG_AUTO_INCREMENT) { if (tokudb_debug & TOKUDB_DEBUG_AUTO_INCREMENT) {
TOKUDB_TRACE("get_auto_increment(%lld,%lld,%lld):got:%lld:%lld\n", TOKUDB_TRACE("get_auto_increment(%lld,%lld,%lld):got:%lld:%lld\n",
......
...@@ -221,6 +221,13 @@ class ha_tokudb : public handler { ...@@ -221,6 +221,13 @@ class ha_tokudb : public handler {
// //
bool range_lock_grabbed; bool range_lock_grabbed;
//
// For bulk inserts, we want option of not updating auto inc
// until all inserts are done. By default, is false
//
bool delay_auto_inc_update;
bool auto_inc_update_req;
// //
// buffer for updating the status of long insert, delete, and update // buffer for updating the status of long insert, delete, and update
// statements. Right now, the the messages are // statements. Right now, the the messages are
...@@ -335,6 +342,9 @@ class ha_tokudb : public handler { ...@@ -335,6 +342,9 @@ class ha_tokudb : public handler {
int update_row(const uchar * old_data, uchar * new_data); int update_row(const uchar * old_data, uchar * new_data);
int delete_row(const uchar * buf); int delete_row(const uchar * buf);
void start_bulk_insert(ha_rows rows);
int end_bulk_insert();
int prepare_index_scan(); int prepare_index_scan();
int prepare_index_key_scan( const uchar * key, uint key_len ); int prepare_index_key_scan( const uchar * key, uint key_len );
int prepare_range_scan( const key_range *start_key, const key_range *end_key); int prepare_range_scan( const key_range *start_key, const key_range *end_key);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment