Index Hints: How to Force Query Plans
Setting up the World Example Database
mariadb-admin create world
zcat world.sql.gz | ../client/mysql worldmariadb-admin create world
gunzip world.sql.gz
../client/mysql world < world.sqlForcing Join Order
SELECT STRAIGHT_JOIN SUM(City.Population) FROM Country,City WHERE
City.CountryCode=Country.Code AND Country.HeadOfState="Volodymyr Zelenskyy";id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra
Forcing Usage of a Specific Index for the WHERE Clause
USE INDEX: Use a Limited Set of Indexes
id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra
IGNORE INDEX: Don't Use a Particular Index
id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra
FORCE INDEX: Forcing an Index
id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra
Index Prefixes
Forcing an Index to be Used for ORDER BY or GROUP BY
id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra
Help the Optimizer Optimize GROUP BY and ORDER BY
Forcing/Disallowing TemporaryTables to be Used for GROUP BY:
id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra
id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra
Forcing Usage of Temporary Tables
id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra
Optimizer Switch
See Also
Last updated
Was this helpful?

