mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
WL#3527: Extend IGNORE INDEX so places where index is ignored
can be specified
Currently MySQL allows one to specify what indexes to ignore during
join optimization. The scope of the current USE/FORCE/IGNORE INDEX
statement is only the FROM clause, while all other clauses are not
affected.
However, in certain cases, the optimizer
may incorrectly choose an index for sorting and/or grouping, and
produce an inefficient query plan.
This task provides the means to specify what indexes are
ignored/used for what operation in a more fine-grained manner, thus
making it possible to manually force a better plan. We do this
by extending the current IGNORE/USE/FORCE INDEX syntax to:
IGNORE/USE/FORCE INDEX [FOR {JOIN | ORDER | GROUP BY}]
so that:
- if no FOR is specified, the index hint will apply everywhere.
- if MySQL is started with the compatibility option --old_mode then
an index hint without a FOR clause works as in 5.0 (i.e, the
index will only be ignored for JOINs, but can still be used to
compute ORDER BY).
See the WL#3527 for further details.
BitKeeper/deleted/.del-mysqld.cc.rej:
Rename: sql/mysqld.cc.rej -> BitKeeper/deleted/.del-mysqld.cc.rej
BitKeeper/deleted/.del-sql_parse.cc.rej:
Rename: sql/sql_parse.cc.rej -> BitKeeper/deleted/.del-sql_parse.cc.rej
BitKeeper/deleted/.del-table.cc.rej:
Rename: sql/table.cc.rej -> BitKeeper/deleted/.del-table.cc.rej
mysql-test/r/endspace.result:
WL3527 : fixed undeterministic test
mysql-test/r/group_by.result:
WL#3527: test cases
mysql-test/t/endspace.test:
WL3527 : fixed undeterministic test
mysql-test/t/group_by.test:
WL#3527: test cases
sql/item.cc:
WL#3527: renames
sql/mysql_priv.h:
WL#3527: corrected initialization
sql/mysqld.cc:
WL#3527: added old_mode command line option
sql/opt_range.cc:
WL#3527: renames
sql/sql_base.cc:
WL#3527:
- renames
- correct initialization
- extended the processing of USE/FORCE/IGNORE index
sql/sql_class.h:
WL#3527: added old_mode command line option
sql/sql_delete.cc:
WL#3527: renames
sql/sql_help.cc:
WL#3527: renames
sql/sql_lex.cc:
WL#3527: extended parsing of USE/FORCE/IGNORE index
sql/sql_lex.h:
WL#3527: extended parsing of USE/FORCE/IGNORE index
sql/sql_parse.cc:
WL#3527: extended parsing of USE/FORCE/IGNORE index
sql/sql_select.cc:
WL#3527:
- renames
- passing additional info to support the extended
USE/FORCE/IGNORE INDEX syntax
- If there is a covering index, and we have
IGNORE INDEX FOR GROUP/ORDER, and this index is
used for the JOIN part, then we have to ignore the
IGNORE INDEX FOR GROUP/ORDER.
sql/sql_show.cc:
WL#3527: passing additional info to support the extended
USE/FORCE/IGNORE INDEX syntax
sql/sql_update.cc:
WL#3527: renames
sql/sql_yacc.yy:
WL#3527: extended parsing of USE/FORCE/IGNORE index
sql/table.cc:
WL#3527: extended the processing of USE/FORCE/IGNORE index
sql/table.h:
WL#3527: extended the processing of USE/FORCE/IGNORE index
storage/myisam/ha_myisam.cc:
WL#3527: extended the processing of USE/FORCE/IGNORE index
This commit is contained in:
@@ -130,7 +130,7 @@ int mysql_update(THD *thd,
|
||||
#endif
|
||||
uint table_count= 0;
|
||||
ha_rows updated, found;
|
||||
key_map old_used_keys;
|
||||
key_map old_covering_keys;
|
||||
TABLE *table;
|
||||
SQL_SELECT *select;
|
||||
READ_RECORD info;
|
||||
@@ -168,8 +168,8 @@ int mysql_update(THD *thd,
|
||||
thd->proc_info="init";
|
||||
table= table_list->table;
|
||||
|
||||
/* Calculate "table->used_keys" based on the WHERE */
|
||||
table->used_keys= table->s->keys_in_use;
|
||||
/* Calculate "table->covering_keys" based on the WHERE */
|
||||
table->covering_keys= table->s->keys_in_use;
|
||||
table->quick_keys.clear_all();
|
||||
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
@@ -179,7 +179,7 @@ int mysql_update(THD *thd,
|
||||
if (mysql_prepare_update(thd, table_list, &conds, order_num, order))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
old_used_keys= table->used_keys; // Keys used in WHERE
|
||||
old_covering_keys= table->covering_keys; // Keys used in WHERE
|
||||
/* Check the fields we are going to modify */
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
table_list->grant.want_privilege= table->grant.want_privilege= want_privilege;
|
||||
@@ -228,7 +228,7 @@ int mysql_update(THD *thd,
|
||||
limit= 0; // Impossible WHERE
|
||||
}
|
||||
// Don't count on usage of 'only index' when calculating which key to use
|
||||
table->used_keys.clear_all();
|
||||
table->covering_keys.clear_all();
|
||||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (prune_partitions(thd, table, conds))
|
||||
@@ -303,7 +303,7 @@ int mysql_update(THD *thd,
|
||||
We can't update table directly; We must first search after all
|
||||
matching rows before updating the table!
|
||||
*/
|
||||
if (used_index < MAX_KEY && old_used_keys.is_set(used_index))
|
||||
if (used_index < MAX_KEY && old_covering_keys.is_set(used_index))
|
||||
{
|
||||
table->key_read=1;
|
||||
table->mark_columns_used_by_index(used_index);
|
||||
@@ -1091,7 +1091,7 @@ int multi_update::prepare(List<Item> ¬_used_values,
|
||||
}
|
||||
|
||||
/*
|
||||
We have to check values after setup_tables to get used_keys right in
|
||||
We have to check values after setup_tables to get covering_keys right in
|
||||
reference tables
|
||||
*/
|
||||
|
||||
@@ -1118,7 +1118,7 @@ int multi_update::prepare(List<Item> ¬_used_values,
|
||||
update.link_in_list((byte*) tl, (byte**) &tl->next_local);
|
||||
tl->shared= table_count++;
|
||||
table->no_keyread=1;
|
||||
table->used_keys.clear_all();
|
||||
table->covering_keys.clear_all();
|
||||
table->pos_in_table_list= tl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user