Answer the question
In order to leave comments, you need to log in
How does mysql decide which indexes to use?
There is a table with 2 separate indexes on gender (tinyint) and age (int)
AND 2 queries
explain select * from test_table where gender = 1 and age = 100;
explain select * from test_table where gender = 1 and age = 101;
type: index_merge
and key: test_table_age_index,test_table_gender_index
- that is, 2 indexes by age and gender are used type: ref и key: test_table_age_index
- that is, only 1 index by age is used
Answer the question
In order to leave comments, you need to log in
Approximately as they said in the comment - scientifically it is called cardinality - https://www.mysqltutorial.org/mysql-index/mysql-in...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question