Salve,
ho una tabella user con migliaia di utenti.
Ho anche una tabella LOG che contiene tutte le attività degli utenti e la data di quando sono state compiute.
La tabella è tipo:
(logId, utenteId, dataInserimento, testoLog)
Ho fatto un index di tipo btree con i campi index(utenteId, dataInserimento) dal nome indice_ut_data.
Se faccio:
explain SELECT * FROM log WHERE utenteId=2 ORDER BY dataInserimento DESC LIMIT 10
mi viene:
1, 'SIMPLE', 'homepage', 'ref', 'Index_u,indice_ut_data', 'indice_ut_data', '4', 'const', 1417352, 'Using where'
Come vedete c'è scritto "using where", che significa che prima prende gli elementi di una certa data e poi fa il where degli utenti. Insomma, c'è qualcosa che non va.
Non dovrebbe usare solamente l'indice?
Come posso ottimizzarla?
Grazie in anticipo