Commit 3d9c8bd7 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:3051], make a default implementation for keyread_time that takes into account clustering keys

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@25843 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6a2d75ee
......@@ -6166,6 +6166,26 @@ double ha_tokudb::scan_time() {
DBUG_RETURN(ret_val);
}
double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows)
{
if (table->key_info[index].flags & HA_CLUSTERING) {
return read_time(index, ranges, rows);
}
/*
It is assumed that we will read trough the whole key range and that all
key blocks are half full (normally things are much better). It is also
assumed that each time we read the next key from the index, the handler
performs a random seek, thus the cost is proportional to the number of
blocks read. This model does not take into account clustered indexes -
engines that support that (e.g. InnoDB) may want to overwrite this method.
*/
double keys_per_block= (stats.block_size/2.0/
(table->key_info[index].key_length +
ref_length) + 1);
return (rows + keys_per_block - 1)/ keys_per_block;
}
//
// Calculate the time it takes to read a set of ranges through an index
// This enables us to optimize reads for clustered indexes.
......
......@@ -404,6 +404,7 @@ public:
}
double scan_time();
double keyread_time(uint index, uint ranges, ha_rows rows);
double read_time(uint index, uint ranges, ha_rows rows);
int open(const char *name, int mode, uint test_if_locked);
......
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