Tenho uma tabela com aproximadamente 80 colunas. Várias delas são indexadas. Elas incluem age
, shoesize
e height
- todas são inteiros.
Tenho então uma consulta que estou tentando otimizar:
select * from people where age > 18 and shoesize > 10 and height > 150
Para tentar acelerar a consulta, criei um novo índice combinado das três colunas em questão - age
, shoesize
e height
. Chamei esse índicecombinedIndex
Se eu então executar:
explain select * from people where age > 18 and shoesize > 10 and height > 150
Então vejo esta saída:
id = 1
select_type = SIMPLE
table = people
type = ALL
possible_keys = age, shoesize, height, combinedIndex
key = NULL
key_len = NULL
ref = NULL
rows = 8947017
extra = using where
Então parece que nenhum índice está sendo usado ao executar minha consulta.
Eu esperava que meu combinedIndex
fosse usado com certeza.
Estou usando o MariaDB 10.6.19
Onde foi que eu errei?