number6
3 weeks ago

MorphToMany with millions of rows?

Posted 3 weeks ago by number6

I've been building out my models & migrations for a new project. Within this app, a user can create many types of lists, we'll say there is a list type 1-9. So the structure might be like:

custom_lists
-id
-user_id
-name

custom_listable
-custom_list_id
-custom_listable_id
-custom_listable_type

list_1
-id
-user_id
-name

list_2
-id
-user_id
-name

list_N
-id
-user_id
-name

A list from any given user can be <10 OR 150K+ items. So in this polymorphic setup, my custom_listable will be millions of rows easily. It's not a public site but if it hits 10 million rows in the first 1-2 years, I wouldn't be surprised.

Will this get really slow or does the index solve all my problems, for years to come? I don't know what the performance on the morphtomany relationships are.

Please sign in or create an account to participate in this conversation.