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

Merge 10.2 into 10.3

This commit is contained in:
Marko Mäkelä
2019-09-23 10:25:34 +03:00
90 changed files with 1022 additions and 555 deletions

View File

@ -2414,12 +2414,16 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
records= head->stat_records();
if (!records)
records++; /* purecov: inspected */
scan_time= (double) records / TIME_FOR_COMPARE + 1;
read_time= (double) head->file->scan_time() + scan_time + 1.1;
if (head->force_index)
if (head->force_index || force_quick_range)
scan_time= read_time= DBL_MAX;
if (limit < records)
read_time= (double) records + scan_time + 1; // Force to use index
else
{
scan_time= (double) records / TIME_FOR_COMPARE + 1;
read_time= (double) head->file->scan_time() + scan_time + 1.1;
if (limit < records)
read_time= (double) records + scan_time + 1; // Force to use index
}
possible_keys.clear_all();
@ -10413,6 +10417,16 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only,
bufsize, mrr_flags, cost);
if (rows != HA_POS_ERROR)
{
ha_rows table_records= param->table->stat_records();
if (rows > table_records)
{
/*
For any index the total number of records within all ranges
cannot be be bigger than the number of records in the table
*/
rows= table_records;
set_if_bigger(rows, 1);
}
param->quick_rows[keynr]= rows;
param->possible_keys.set_bit(keynr);
if (update_tbl_stats)