diff options
author | Monty <monty@mariadb.org> | 2020-02-28 12:59:30 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2020-03-27 03:58:32 +0200 |
commit | eb483c5181ab430877c135c16224284cfc517b3d (patch) | |
tree | 05fc0a6583a84b51c84e72b69191974c4d9ca8c8 /storage/rocksdb/mysql-test | |
parent | b3ab3105fdb34dae6c2d4270751bc0694c3d9df8 (diff) | |
download | mariadb-git-eb483c5181ab430877c135c16224284cfc517b3d.tar.gz |
Updated optimizer costs in multi_range_read_info_const() and sql_select.cc
- multi_range_read_info_const now uses the new records_in_range interface
- Added handler::avg_io_cost()
- Don't calculate avg_io_cost() in get_sweep_read_cost if avg_io_cost is
not 1.0. In this case we trust the avg_io_cost() from the handler.
- Changed test_quick_select to use TIME_FOR_COMPARE instead of
TIME_FOR_COMPARE_IDX to align this with the rest of the code.
- Fixed bug when using test_if_cheaper_ordering where we didn't use
keyread if index was changed
- Fixed a bug where we didn't use index only read when using order-by-index
- 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 get_sweep_read_cost() for HEAP tables
- Ensure that range and ref have same cost for simple ranges
Added a small cost (MULTI_RANGE_READ_SETUP_COST) to ranges to ensure
we favior ref for range for simple queries.
- Fixed that matching_candidates_in_table() uses same number of records
as the rest of the optimizer
- Added avg_io_cost() to JT_EQ_REF cost. This helps calculate the cost for
HEAP and temporary tables better. A few tests changed because of this.
- heap::read_time() and heap::keyread_time() adjusted to not add +1.
This was to ensure that handler::keyread_time() doesn't give
higher cost for heap tables than for normal tables. One effect of
this is that heap and derived tables stored in heap will prefer
key access as this is now regarded as cheap.
- Changed cost for index read in sql_select.cc to match
multi_range_read_info_const(). All index cost calculation is now
done trough one function.
- 'ref' will now use quick_cost for keys if it exists. This is done
so that for '=' ranges, 'ref' is prefered over 'range'.
- scan_time() now takes avg_io_costs() into account
- get_delayed_table_estimates() uses block_size and avg_io_cost()
- Removed default argument to test_if_order_by_key(); simplifies code
Diffstat (limited to 'storage/rocksdb/mysql-test')
6 files changed, 15 insertions, 13 deletions
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result b/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result index 6507aa43ae1..b8cb4157d37 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result @@ -1808,10 +1808,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by explain select distinct a1,a2,b from t2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by @@ -1978,10 +1978,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by explain select distinct a1,a2,b from t2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by @@ -2131,7 +2131,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_2 147 NULL 9 Using index for group-by select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; a1 a2 b concat(min(c), max(c)) a a a a111d111 @@ -2285,7 +2285,7 @@ c d explain select a1 from t1 where a2 = 'b' group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-by +1 SIMPLE t1 range NULL idx_t1_2 130 NULL 5 Using where; Using index for group-by select a1 from t1 where a2 = 'b' group by a1; a1 a @@ -2294,7 +2294,7 @@ c d explain select distinct a1 from t1 where a2 = 'b'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-by +1 SIMPLE t1 range NULL idx_t1_2 130 NULL 5 Using where; Using index for group-by select distinct a1 from t1 where a2 = 'b'; a1 a diff --git a/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result b/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result index efc6ccde500..4f285134c00 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result @@ -34,6 +34,7 @@ Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 FLUSH STATUS; +SET GLOBAL rocksdb_force_flush_memtable_and_lzero_now=1; SELECT * FROM t1 WHERE b=6; id a b 6 NULL 6 diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result index efe4eaf2141..d96c40127a8 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result @@ -63,7 +63,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 ALL i1 NULL NULL NULL # Using where explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 ref i1,i2,i3 i3 4 const # Using where +1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where explain select * from t0 use index (i1,i2) where (key1 < 2 or key2 <3) and key3 = 50; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where @@ -121,11 +121,11 @@ id select_type table type possible_keys key key_len ref rows Extra explain select * from t0 where (key1 < 3 or key2 < 3) and (key3 < 70); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 range i1,i2,i3 i3 4 NULL # Using index condition; Using where +1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where explain select * from t0 where (key1 < 3 or key2 < 3) and (key3 < 1000); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 range i1,i2,i3 i3 4 NULL # Using index condition; Using where +1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where explain select * from t0 where ((key1 < 3 or key2 < 3) and (key2 <4 or key3 < 3)) or diff --git a/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result b/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result index ce3d7d9147e..feeabd7ee79 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result @@ -67,7 +67,7 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 700 explain extended select a,b from t1 where a = 700; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ref ka ka 5 const 15000 100.00 +1 SIMPLE t1 ALL ka NULL NULL NULL 20000 75.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` = 700 explain extended select a from t1 where a in (700, 800); diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result index 99d6bbe45b9..ca6ed6d5d18 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result @@ -114,7 +114,7 @@ INSERT INTO t1 (f,r,d,dp,pk) VALUES (4644,1422.22,466664.999,0.5,5); EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL d 9 NULL # Using index +1 SIMPLE t1 range NULL d 9 NULL # Using index for group-by SELECT DISTINCT d FROM t1 ORDER BY d; d -1 @@ -177,7 +177,7 @@ INSERT INTO t1 (f,r,d,dp,pk) VALUES (1.2345,0,0,0,6); EXPLAIN SELECT DISTINCT f FROM t1 ORDER BY f; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL f 5 NULL # Using index +1 SIMPLE t1 range NULL f 5 NULL # Using index for group-by SELECT DISTINCT f FROM t1 ORDER BY f; f -1 diff --git a/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test b/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test index 7b1652c759b..22b5d69780d 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test @@ -28,6 +28,7 @@ SELECT * FROM t1 WHERE id=8; SHOW SESSION STATUS LIKE 'Handler_read%'; FLUSH STATUS; +SET GLOBAL rocksdb_force_flush_memtable_and_lzero_now=1; SELECT * FROM t1 WHERE b=6; SHOW SESSION STATUS LIKE 'Handler_read%'; |