I want to decrease the load time from 2.5 secs for a mysql count query. All columns in the query have a index.
SELECT COUNT(1)
FROM song AS s
JOIN song_text AS st
ON(st.song_id = s.song_id)
JOIN phpfox_user AS u
ON(u.user_id = s.user_id)
WHERE st.lyrics LIKE '%a%' AND s.is_active = 1 AND s.public = 1
The query getting the returned rows load in 0.0009060 seconds.
SELECT s.*, st.lyrics, u.first_name
FROM song AS s
JOIN song_text AS st
ON(st.song_id = s.song_id)
JOIN phpfox_user AS u
ON(u.user_id = s.user_id)
WHERE st.lyrics LIKE '%a%' AND s.is_active = 1 AND s.public = 1
ORDER BY s.date_added DESC
LIMIT 12
Why does the count query have a significantly more load time than the query returning the rows? What can be done to reduce the load time for the count query to something similar to other query?