diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-23 17:35:29 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-23 17:35:29 +0300 |
commit | 5a92ccbaea1bb3973e23846a741f5694a1e687bd (patch) | |
tree | aafc504552502b48b79cadcb06b2b5c7eba4f374 /sql/opt_range.cc | |
parent | c997af7d1f432dfca922958453f0e2313287f1eb (diff) | |
parent | c016ea660ede8b7ff75f8ca65f73e2958262263a (diff) | |
download | mariadb-git-5a92ccbaea1bb3973e23846a741f5694a1e687bd.tar.gz |
Merge 10.3 into 10.4
Disable MDEV-20576 assertions until MDEV-20595 has been fixed.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 3f8509a4b47..654fab7810a 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2661,12 +2661,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(); @@ -11069,6 +11073,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) |