1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Added keyread_time() to HEAP

The default keyread_time() was optimized for blocks and not suitable for
HEAP. The effect was the HEAP prefered table scans over ranges for btree
indexes.
Fixed also get_sweep_read_cost() for HEAP tables.
This commit is contained in:
Monty
2020-03-05 14:10:03 +02:00
parent a24d0926b9
commit c037cdadf4
6 changed files with 15 additions and 11 deletions

View File

@ -2675,11 +2675,13 @@ double handler::keyread_time(uint index, uint ranges, ha_rows rows)
size_t len= table->key_info[index].key_length + ref_length;
if (index == table->s->primary_key && table->file->primary_key_is_clustered())
len= table->s->stored_rec_length;
uint keys_per_block= (uint) (stats.block_size/2.0/len+1);
ulonglong blocks= !rows ? 0 : (rows-1) / keys_per_block + 1;
double cost= (double)rows*len/(stats.block_size+1)*IDX_BLOCK_COPY_COST;
if (ranges)
{
uint keys_per_block= (uint) (stats.block_size/2.0/len+1);
ulonglong blocks= !rows ? 0 : (rows-1) / keys_per_block + 1;
cost+= blocks;
}
return cost;
}