我們看到MySQL需要添加rangeswhen計算ha_innobase::read_time(/storage/innobase/handler/ha_innobase.cc),我的問題是為什么需要它?
double ha_innobase::read_time(
uint index, /*!< in: key number */
uint ranges, /*!< in: how many ranges */
ha_rows rows) /*!< in: estimated number of rows in the ranges */
{
ha_rows total_rows;
if (index != table->s->primary_key) {
/* Not clustered */
return(handler::read_time(index, ranges, rows));
}
if (rows <= 2) {
return((double) rows);
}
/* Assume that the read time is proportional to the scan time for all
rows at most one seek per range. */
double time_for_scan = scan_time();
if ((total_rows = estimate_rows_upper_bound()) < rows) {
return(time_for_scan);
}
return(ranges (double) rows / (double) total_rows * time_for_scan);
}
uj5u.com熱心網友回復:
這條評論告訴你答案:
/* Assume that the read time is proportional to the scan time for all
rows at most one seek per range. */
每個范圍可能都有一次搜索,每次搜索都會增加讀取時間。旋轉存盤設備上的尋道成本更高,現在大多數站點都使用固態存盤,但尋道的成本仍然有點高。所以在計算總讀取時間時計算它們很重要。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/401820.html
上一篇:檢查公寓的可用性
