I am querying database with follwing query.
This query takes 21 seconds to execute.
I have check it by explain query.
I have index on fields groupId
, batchId
separately.
EXPLAIN SELECT message, sentOn, maskId, isDndCheck, contentType
FROM sms_histories
WHERE groupId = 1750
GROUP BY batchId
ORDER BY batchId DESC
LIMIT 0 , 1
I am getting group's last post by this query.
My explain query shows me result
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE sms_histories index groupId batchId 5 NULL 888 Using where
please tell me what is the problem , why this query takes this much long time?