I have a join table in my application’s database (MySQL) which grows massively.
I have 2 models user and product, user has many products to view, and products belongs to many users how will view it.
on start all users has all products to view and the user can edit which products he can view.
the problem that the table size will be (n*m) n is number of users (which is large) and m is number of products (which is large too), and read operations on the table will be slow.
Example:
I have 3 Users their id’s : “1,2,3”
and 3 products their id’s : “1,2,3”
so the users_products table will be:
user_id, product_id
1 , 1
1 , 2
1 , 3
2 , 1
2 , 2
2 , 3
3 , 1
3 , 2
3 , 3
I’m open to all solutions, starting from redesigning this part to use another database system.
Thanks in advance.
I think your assuming something that probably isn’t true. SQL servers are quick with these kind of queries even with a lot of rows. Tables with 10 million records can be queried pretty fast if you have good indices.
I would recommend some testing before you make all kinds of premature optimizations.