My mysql query looks like this:
SELECT pages.*,
showcase.*,
project.*
FROM pages
INNER JOIN showcase ON showcase.pid = pages.uid AND showcase.deleted != 1
INNER JOIN project ON FIND_IN_SET(project.uid, showcase.projects)
WHERE pages.deleted != 1
AND pages.pid = 14
AND pages.dokType = 150
The problem is the second INNER JOIN
- it uses FIND_IN_SET
because a showcase (= collection of projects) stores its projects as a comma separated list in the field showcase.projects
. FIND_IN_SET
cant use indexes as far as I know, so the second join requires a full table scan of the project table. Any possibility to use an index without changing the database scheme?