1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +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

@ -358,6 +358,7 @@ typedef struct st_join_table {
/* set by estimate_scan_time() */
double cached_scan_time;
double cached_scan_and_compare_time;
double cached_forced_index_cost;
/*
dependent is the table that must be read before the current one
@ -406,7 +407,8 @@ typedef struct st_join_table {
uint used_blobs;
uint used_null_fields;
uint used_uneven_bit_fields;
enum join_type type;
uint cached_forced_index;
enum join_type type, cached_forced_index_type;
/* If first key part is used for any key in 'key_dependent' */
bool key_start_dependent;
bool cached_eq_ref_table,eq_ref_table;
@ -1044,7 +1046,7 @@ public:
are covered by the specified semi-join strategy
*/
uint n_sj_tables;
uint forced_index; // If force_index() is used
/*
TRUE <=> join buffering will be used. At the moment this is based on
*very* imprecise guesses made in best_access_path().