Commit eb085d7a authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1418

show progress after every 1000 deletes, inserts, or updates

git-svn-id: file:///svn/mysql/tokudb-engine/src@9068 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3fbfb160
...@@ -187,6 +187,9 @@ ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg) ...@@ -187,6 +187,9 @@ ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg)
HA_FILE_BASED | HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX |HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE), HA_FILE_BASED | HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX |HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE),
added_rows(0), deleted_rows(0), last_dup_key((uint) - 1), using_ignore(0), last_cursor_error(0),range_lock_grabbed(false), primary_key_offsets(NULL) { added_rows(0), deleted_rows(0), last_dup_key((uint) - 1), using_ignore(0), last_cursor_error(0),range_lock_grabbed(false), primary_key_offsets(NULL) {
transaction = NULL; transaction = NULL;
num_added_rows_in_stmt = 0;
num_deleted_rows_in_stmt = 0;
num_updated_rows_in_stmt = 0;
} }
static const char *ha_tokudb_exts[] = { static const char *ha_tokudb_exts[] = {
...@@ -1883,6 +1886,11 @@ int ha_tokudb::write_row(uchar * record) { ...@@ -1883,6 +1886,11 @@ int ha_tokudb::write_row(uchar * record) {
DB_TXN* sub_trans = NULL; DB_TXN* sub_trans = NULL;
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
//
// status message to be shown in "show process list"
//
char status_msg[200]; //buffer of 200 should be a good upper bound.
// //
// some crap that needs to be done because MySQL does not properly abstract // some crap that needs to be done because MySQL does not properly abstract
// this work away from us, namely filling in auto increment and setting auto timestamp // this work away from us, namely filling in auto increment and setting auto timestamp
...@@ -2003,6 +2011,11 @@ int ha_tokudb::write_row(uchar * record) { ...@@ -2003,6 +2011,11 @@ int ha_tokudb::write_row(uchar * record) {
if (!error) { if (!error) {
added_rows++; added_rows++;
num_added_rows_in_stmt++;
if ((num_added_rows_in_stmt % 1000) == 0) {
sprintf(status_msg, "Inserted about %llu rows", num_added_rows_in_stmt);
thd_proc_info(thd, status_msg);
}
} }
cleanup: cleanup:
if (error == DB_KEYEXIST) { if (error == DB_KEYEXIST) {
...@@ -2093,6 +2106,10 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { ...@@ -2093,6 +2106,10 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) {
THD* thd = ha_thd(); THD* thd = ha_thd();
DB_TXN* sub_trans = NULL; DB_TXN* sub_trans = NULL;
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
//
// status message to be shown in "show process list"
//
char status_msg[200]; //buffer of 200 should be a good upper bound.
LINT_INIT(error); LINT_INIT(error);
statistic_increment(table->in_use->status_var.ha_update_count, &LOCK_status); statistic_increment(table->in_use->status_var.ha_update_count, &LOCK_status);
...@@ -2206,6 +2223,13 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { ...@@ -2206,6 +2223,13 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) {
} }
} }
if (!error) {
num_updated_rows_in_stmt++;
if ((num_updated_rows_in_stmt % 1000) == 0) {
sprintf(status_msg, "Inserted about %llu rows", num_updated_rows_in_stmt);
thd_proc_info(thd, status_msg);
}
}
cleanup: cleanup:
...@@ -2314,6 +2338,11 @@ int ha_tokudb::delete_row(const uchar * record) { ...@@ -2314,6 +2338,11 @@ int ha_tokudb::delete_row(const uchar * record) {
DBT prim_key; DBT prim_key;
key_map keys = table_share->keys_in_use; key_map keys = table_share->keys_in_use;
bool has_null; bool has_null;
//
// status message to be shown in "show process list"
//
char status_msg[200]; //buffer of 200 should be a good upper bound.
THD* thd = ha_thd();
statistic_increment(table->in_use->status_var.ha_delete_count, &LOCK_status); statistic_increment(table->in_use->status_var.ha_delete_count, &LOCK_status);
create_dbt_key_from_table(&prim_key, primary_key, key_buff, record, &has_null); create_dbt_key_from_table(&prim_key, primary_key, key_buff, record, &has_null);
...@@ -2329,6 +2358,11 @@ int ha_tokudb::delete_row(const uchar * record) { ...@@ -2329,6 +2358,11 @@ int ha_tokudb::delete_row(const uchar * record) {
} }
else { else {
deleted_rows++; deleted_rows++;
num_deleted_rows_in_stmt++;
if ((num_deleted_rows_in_stmt % 1000) == 0) {
sprintf(status_msg, "Inserted about %llu rows", num_deleted_rows_in_stmt);
thd_proc_info(thd, status_msg);
}
} }
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
...@@ -3466,6 +3500,14 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) { ...@@ -3466,6 +3500,14 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
ulong tx_isolation = thd_tx_isolation(thd); ulong tx_isolation = thd_tx_isolation(thd);
HA_TOKU_ISO_LEVEL toku_iso_level = tx_to_toku_iso(tx_isolation); HA_TOKU_ISO_LEVEL toku_iso_level = tx_to_toku_iso(tx_isolation);
tokudb_trx_data *trx = NULL; tokudb_trx_data *trx = NULL;
//
// reset per-stmt variables
//
num_added_rows_in_stmt = 0;
num_deleted_rows_in_stmt = 0;
num_updated_rows_in_stmt = 0;
trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot); trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
if (!trx) { if (!trx) {
trx = (tokudb_trx_data *) my_malloc(sizeof(*trx), MYF(MY_ZEROFILL)); trx = (tokudb_trx_data *) my_malloc(sizeof(*trx), MYF(MY_ZEROFILL));
...@@ -3612,6 +3654,14 @@ cleanup: ...@@ -3612,6 +3654,14 @@ cleanup:
int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) { int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) {
TOKUDB_DBUG_ENTER("ha_tokudb::start_stmt"); TOKUDB_DBUG_ENTER("ha_tokudb::start_stmt");
int error = 0; int error = 0;
//
// reset per-stmt variables
//
num_added_rows_in_stmt = 0;
num_deleted_rows_in_stmt = 0;
num_updated_rows_in_stmt = 0;
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot); tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
DBUG_ASSERT(trx); DBUG_ASSERT(trx);
/* /*
......
...@@ -150,10 +150,26 @@ private: ...@@ -150,10 +150,26 @@ private:
// //
ulong int_table_flags; ulong int_table_flags;
// //
// count on the number of rows that gets changed, such as when write_row occurs // count on the number of rows that gets changed, such as when write_row occurs
// this is meant to help keep estimate on number of elements in DB
// //
ulonglong added_rows; ulonglong added_rows;
ulonglong deleted_rows; ulonglong deleted_rows;
//
// count on number of rows inserted by statement
// this is to help give user progress on what is happening
// the reason that the variables added_rows and deleted_rows
// are not used is that those variables are also used to help
// estimate the number of rows in the DB. There are tricky things that
// can happen with "lock tables", so I do not want to couple these
// two features together. There is a little duplicate work, but I think it is fine
//
ulonglong num_added_rows_in_stmt;
ulonglong num_deleted_rows_in_stmt;
ulonglong num_updated_rows_in_stmt;
// //
// index into key_file that holds DB* that is indexed on // index into key_file that holds DB* that is indexed on
// the primary_key. this->key_file[primary_index] == this->file // the primary_key. this->key_file[primary_index] == this->file
......
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