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

Fixed some issues with FORCE INDEX

Added code to support that force index can be used to force an index scan
instead of a full table scan. Currently this code is disable but I added
a test to verify that things works if the code is ever enabled.

Other things:

- FORCE INDEX will now work with "Range checked for each record" and
  join cache (see main/type_time_6065)
- Removed code ifdef with BAD_OPTIMIZATION (New cost calculations should
  fix this).
- Removed TABLE_LIST->force_index and comment that it should be removed
- Added TABLE->force_index_join and use in the corresponding places.
  This means that FORCE INDEX FOR ORDER BY will not affect keys used
  in joins anymore.
  Remove TODO that the above should be added.
  I still kept TABLE->force_index as it's used in
  test_if_cheaper_ordering() and opt_range.cc
- Removed setting table->force_index when calling test_quick_select() as
  it's not needed (force_index is an argument to test_quick_select())
This commit is contained in:
Michael Widenius
2022-08-20 08:22:57 +03:00
committed by Sergei Petrunia
parent 013ba37ae2
commit 33fc8037e0
9 changed files with 236 additions and 105 deletions

View File

@ -611,3 +611,23 @@ drop table t1,t2;
--echo #
create table t1 (a int, b int, key(a), key(a desc));
drop table t1;
--echo # Check some issues with FORCE INDEX and full index scans
--echo # (Does FORCE INDEX force an index scan)
--echo #
create table t1 (a int primary key, b int, c int, d int,
key k1 (b) using BTREE, key k2 (c,d) using btree) engine=heap;
insert into t1 select seq as a, seq as b, seq as c, seq as d
from seq_1_to_100;
explain select sum(a+b) from t1 force index (k1) where b>0 and a=99;
explain select sum(a+b) from t1 force index (k1) where a>0;
explain select sum(a+b) from t1 force index (k1);
explain select sum(a+b) from t1 force index for join (k1);
explain select sum(a+b) from t1 force index for order by (k1);
explain select sum(a+b) from t1 force index (k1,k2);
select sum(a+b) from t1 force index (k1);
explain select sum(a+b) from t1 force index (primary);
select sum(a+b) from t1 force index (primary);
explain select straight_join sum(a+b) from seq_1_to_10 as s, t1 force index (k2) where t1.a=s.seq;
drop table t1;