Assume that I have 2 big tables with more than 1 million rows in each table.
Table 1 Describing the user, a movie table with a User ID looks at this movie, and hosts the music with Table 2 users who tilt the song to the user.
What I want to do is enable to run a query whenever the user wants to know if there is a song with the same name as the movie that he has seen.
For example.
Select movies from movies. Name, music WHERE movies.name = music.name and movies.userID = '8a80828c2b46d717012b4801d2650002';
I have indexed the movie name and music name in both tables. The problem occurs when the user asks the query, it seems that depending on how many rows it relies on tables and how many movies / music the user has seen / swarm
assume that the user has 9000 movies and Swarm watched 90k songs. How would I go about optimizing this query for fast (max 15 seconds)?
EDIT: Is it possible for me to use triggers after every watch movie and check that there is a song or not there is a third table with the User ID, MovieID, Music ID Updating more? Will the database performance be affected due to the increasing volume of data coming into the database?
Select names from songs where in the name (select the names of movies where userID = 5); Select s.name from
OR
songs (select the names of movies where userid = 5) on s.name = m.name As the m;
- Put an index on the useride in the movie
- Keep an index on the name in the songs
Comments
Post a Comment