mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
better fix for MySQL bugs
BUG#26447 prefer a clustered key for an index scan, as secondary index is always slower ... which was fixed to cause BUG#35850 queries take 50% longer ... and was reverted and BUG#39653 prefer a secondary index for an index scan, as clustered key is always slower ... which was fixed to cause BUG#55656 mysqldump takes six days instead of half an hour ... and was amended with a special case workaround sql/opt_range.cc: move get_index_only_read_time() into the handler class sql/sql_select.cc: use cost not an index length when choosing a cheaper index
This commit is contained in:
@ -2047,7 +2047,21 @@ handler *handler::clone(MEM_ROOT *mem_root)
|
||||
return new_handler;
|
||||
}
|
||||
|
||||
|
||||
double handler::keyread_time(uint index, uint ranges, ha_rows 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;
|
||||
}
|
||||
|
||||
void handler::ha_statistic_increment(ulong SSV::*offset) const
|
||||
{
|
||||
|
Reference in New Issue
Block a user