mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
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
This commit is contained in:
parent
d79ef6e57f
commit
9b2d2bea0f
2 changed files with 42 additions and 0 deletions
|
@ -3493,6 +3493,47 @@ double ha_tokudb::scan_time() {
|
||||||
DBUG_RETURN(ret_val);
|
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
|
// 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
|
// HA_TOKUDB_RANGE_COUNT instead of HA_POS_ERROR. This was behavior
|
||||||
|
|
|
@ -204,6 +204,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
double scan_time();
|
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 open(const char *name, int mode, uint test_if_locked);
|
||||||
int close(void);
|
int close(void);
|
||||||
|
|
Loading…
Add table
Reference in a new issue