I have a problem with the following query which is very slow :
SELECT A.* FROM B INNER JOIN A ON A.id=B.fk_A WHERE A.creationDate BETWEEN '20120309' AND '20120607' GROUP BY A.id ORDER BY RAND() LIMIT 0,5
EXPLAIN :
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE B index fk_A fk_A 4 \N 58962 Using index; Using temporary; Using filesort 1 SIMPLE A eq_ref PRIMARY,creationDate PRIMARY 4 B.fk_A 1 Using where
INDEXES :
A.id (int) = PRIMARY index A.creationDate (date) = index B.fk_A = index
Do you see something to optimize ?
Thanks a lot for your advice
LIMIT
? – ypercubeᵀᴹ