I have a site where people can add their favorite TV series. There is one feature that makes it possible to check off episodes that you have seen.
Each episodes that is checked off, creates one record in a DB table (with user_id, show_id and episode_id).
This table is now over 600.000 rows and is growing very fast!
I have indexes set up, but I feel like the performance when querying this table is getting worse and worse.
My thoughts for a new solution:
So instead of:
user_id | show_id | episode_id
1 ....... 123 ......7675
1 ....... 123 ......7676
1 ....... 123 ......7677
1 ....... 456 ......5678
1 ....... 456 ......5679
1 ....... 456 ......5680
I could do this:
user_id | show_id | episode_ids
1 ....... 123 ......7675,7676,7677
1 ....... 456 ......5678,5679,5680
Then I would have to split the string into an array, and use array.include?(some-id).
This should relieve the database, but there would be much heavier array code for Ruby to handle.
Am I on the right track? Or can anybody think of a better solution?