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

addresses #895

implement read_time to take into account that the primary_key is clustered

git-svn-id: file:///svn/mysql/tokudb-engine/src@4595 c7de825b-a66e-492c-adef-691d508d4ae1
parent 62deaba0
......@@ -3493,6 +3493,47 @@ double ha_tokudb::scan_time() {
DBUG_RETURN(ret_val);
}
//
// Calculate the time it takes to read a set of ranges through an index
// This enables us to optimize reads for clustered indexes.
// Implementation pulled from InnoDB
// Parameters:
// index - index to use
// ranges - number of ranges
// rows - estimated number of rows in the range
// Returns:
// estimated time measured in disk seeks
//
double ha_tokudb::read_time(
uint index,
uint ranges,
ha_rows rows
)
{
double total_scan;
double ret_val;
if (index != primary_key) {
ret_val = handler::read_time(index, ranges, rows);
goto cleanup;
}
total_scan = scan_time();
if (stats.records < rows) {
ret_val = total_scan;
goto cleanup;
}
//
// one disk seek per range plus the proportional scan time of the rows
//
ret_val = (ranges + (double) rows / (double) stats.records * total_scan);
cleanup:
return ret_val;
}
//
// Estimates the number of index records in a range. In case of errors, return
// HA_TOKUDB_RANGE_COUNT instead of HA_POS_ERROR. This was behavior
......
......@@ -204,6 +204,7 @@ class ha_tokudb : public handler {
}
double scan_time();
double read_time(uint index, uint ranges, ha_rows rows);
int open(const char *name, int mode, uint test_if_locked);
int close(void);
......
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