diff options
Diffstat (limited to 'storage/rocksdb/ha_rocksdb.cc')
-rw-r--r-- | storage/rocksdb/ha_rocksdb.cc | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 8067d6f6..4ab02520 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -5235,6 +5235,24 @@ static int rocksdb_check_version(handlerton *hton, return (create_id == ver); } + +/* + Setup costs factors for RocksDB to be able to approximate how many + ms different opperations takes. See cost functions in handler.h how + the different variables are used +*/ + +static void rocksdb_update_optimizer_costs(OPTIMIZER_COSTS *costs) +{ + /* See optimizer_costs.txt for how these are calculated */ + costs->row_next_find_cost= 0.00015161; + costs->row_lookup_cost= 0.00150453; + costs->key_next_find_cost= 0.00025108; + costs->key_lookup_cost= 0.00079369; + costs->row_copy_cost= 0.00006087; +} + + /* Storage Engine initialization function, invoked when plugin is loaded. */ @@ -5343,6 +5361,7 @@ static int rocksdb_init_func(void *const p) { rocksdb_hton->savepoint_rollback = rocksdb_rollback_to_savepoint; rocksdb_hton->savepoint_rollback_can_release_mdl = rocksdb_rollback_to_savepoint_can_release_mdl; + rocksdb_hton->update_optimizer_costs= rocksdb_update_optimizer_costs; #ifdef MARIAROCKS_NOT_YET rocksdb_hton->update_table_stats = rocksdb_update_table_stats; #endif // MARIAROCKS_NOT_YET @@ -6466,7 +6485,7 @@ bool ha_rocksdb::should_hide_ttl_rec(const Rdb_key_def &kd, /* increment examined row count when rows are skipped */ THD *thd = ha_thd(); - thd->inc_examined_row_count(1); + thd->inc_examined_row_count(); DEBUG_SYNC(thd, "rocksdb.ttl_rows_examined"); } return is_hide_ttl; @@ -14631,17 +14650,25 @@ bool ha_rocksdb::use_read_free_rpl() const { } #endif // MARIAROCKS_NOT_YET -double ha_rocksdb::read_time(uint index, uint ranges, ha_rows rows) { +IO_AND_CPU_COST ha_rocksdb::keyread_time(uint index, ulong ranges, + ha_rows rows, + ulonglong blocks) { DBUG_ENTER_FUNC(); + IO_AND_CPU_COST cost; + cost= handler::keyread_time(index, ranges, rows, blocks); + cost.io/= 4; // Assume 75% compression (75% less IO) + DBUG_RETURN(cost); +} - if (index != table->s->primary_key) { - /* Non covering index range scan */ - DBUG_RETURN(handler::read_time(index, ranges, rows)); - } - DBUG_RETURN((rows / 20.0) + 1); +ulonglong ha_rocksdb::index_blocks(uint index, uint ranges, ha_rows rows) +{ + size_t len= table->key_storage_length(index); + ulonglong blocks= (rows * len / 4) / stats.block_size + ranges; // 75 % compression + return blocks * stats.block_size / IO_SIZE; } + void ha_rocksdb::print_error(int error, myf errflag) { if (error == HA_ERR_ROCKSDB_STATUS_BUSY) { error = HA_ERR_LOCK_DEADLOCK; |