public-activity / public_activity

Easy activity tracking for models - similar to Github's Public Activity

Home Page:https://github.com/pokonski/public_activity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make owner relation non-polymorphic via configuration

yjukaku opened this issue · comments

We have a large activities table with a lot of records, around 27 million - for that reason, we want to improve performance however we can.

One thing we noticed is that our index on [owner_id, owner_type] is quite large, almost the size of the table itself. An index on just owner_id is less than a quarter of the size. Since in our application an Activity's owner is always the same class (User) I was wondering if there was anyway to configure public_activity to make the relationship non-polymorphic?

If not, would you accept a PR to allow this?

At this scale and with such a custom requirement I would advise just running with your own implemention of PublicActivity. At its core it is really simple to do - especially since you can just cherry pick what you use from our codebase :)

Alternatively you could drop that index and create a partial one just for owner_id with condition owner_type = 'User'.

Maintaining both polymorphic and non-polymorphic options is a bigger burden than I can take on right now.

👍 Thanks, and good suggestion about the condition on an index.