So this was a small site that got extremely popular very fast and now and im having major problems with the below sql query.
I understand that my DB design is not great. I have text field for subjects and programs witch contains a serialized array and i search it using like.
the below query takes about a minute.
SELECT p.*, e.institution
FROM cv_personal p
LEFT JOIN cv_education e
ON p.id = e.user_id
LEFT JOIN cv_literacy l
ON p.id = l.user_id
WHERE 1 = 1
AND (e.qualification LIKE '%php%' OR e.subjects LIKE '%php%' OR l.programs LIKE '%php%')
GROUP BY p.id
ORDER BY p.created_on DESC
What an EXPLAIN show ?
I think you can add conditions to a join to reduce number of records which are used :
And why do you use GROUP BY ?