Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue with a large target collection #148

Open
markedmondson opened this issue Sep 2, 2020 · 0 comments
Open

Performance issue with a large target collection #148

markedmondson opened this issue Sep 2, 2020 · 0 comments

Comments

@markedmondson
Copy link
Contributor

Steps to reproduce

In NotificationApi#notify the call to targets.blank? (https://github.com/simukappu/activity_notification/blob/master/lib/activity_notification/apis/notification_api.rb#L231) loads all of the targets, for a large collection, this loads all the records into memory and it seems pretty pointless as the subsequent call is to NotificationApi#notify_all which iterates the enumerable.

Additionally, that map call in NotificationApi#notify_all (https://github.com/simukappu/activity_notification/blob/master/lib/activity_notification/apis/notification_api.rb#L293) also loads all of the collection objects into memory, it'd be nicer if we could use something like .in_batches from the relation in order to do this with more performance on a large set.

Making this change would require a change to the API though as returning an Array of the generated notifications will be trickier, additionally, it looks like the NotifyAllJob passes the collection and not the relation.

I'm happy to open a PR if you have some ideas on what might make a good approach.

System configuration

activity_notification gem version: 2.1.3
Rails version: 6.0
ORM (ActiveRecord, Mongoid or Dynamoid): AR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants