Query in PHP File (SQL Fiddle)
SELECT tmdb_movies.movie_title,tmdb_movies.tmdb_id
,GROUP_CONCAT(DISTINCT videos.videos_key) as videos_key
,GROUP_CONCAT(DISTINCT videos.videos_name) as videos_name
,GROUP_CONCAT(DISTINCT genres.genres_name) AS genres_name
FROM tmdb_movies
LEFT JOIN videos ON videos.videos_tmdb_id=tmdb_movies.tmdb_id
JOIN genres USING (tmdb_id)
GROUP BY tmdb_movies.movie_title,tmdb_movies.tmdb_id
HAVING find_in_set('$category1', genres_name) $andor find_in_set('$category2', genres_name)
ORDER BY $sortby $order LIMIT 10 OFFSET $start
In this query: $category1 and $category2 are variables like (Action, Crime, Horror, Comedy etc)
$andor is an variable. It's value is AND, if both variables $category1 and $category2 have values.
If only $category1 have value, then $andor variable value is OR
Here this 10 querys take around 4-6 seconds to display. My expected speed is less than
0.1 seconds. I have around 80k rows and 35 columns in MySQL tables.
My Indexes
create index idxm on tmdb_movies(tmdb_id);
create index idxv on videos(videos_tmdb_id, videos_name, videos_key);
create index idxv on genres(tmdb_id, genres_name);
tmdb_movies table:
tmdb_id movie_title
1 Logan
2 Iron Man
3 Superman
genres table
tmdb_id genres_name
1 Crime
1 Comedy
1 Drama
2 Action
2 Horror
2 Documentary
3 Music
videos table
videos_tmdb_id videos_name
1 Official Trailer
1 Trailer 2
2 Trailer 1
2 Trailer 2 HD
3 Superman Trailer 1
3 Superman Trailer 2
Let me know, if you need more information
Edit: Explain Query Screeshot

EXPLAINon your query?GROUP BY, but those calls toFIND_IN_SET()could be costly. You might want to normalize your data and avoid making them.GROUP BYorFind_IN_SET()? Any other query sir?