PRX / apn_on_rails

Apple Push Notifications on Rails
http://rubydoc.info/github/PRX/apn_on_rails/master/frames
MIT License
538 stars 156 forks source link

APN::App.send_notifications results in high DB load #20

Open andreasmueller opened 13 years ago

andreasmueller commented 13 years ago

Hello

we recently switched from wireframe apn_on_rails to PRX apn_on_rails (0.4.1), and we noticed a significant increase in DB load. It seems that this is due to a nested loop in the function send_notifications_for_cert (in the app model), which creates a DB query for each device, whereas the wireframe version uses a simple APN::Notification.all(:conditions => {:sent_at => nil}) to find all notifications to send.

I understand the benefit of being able to specify an app_id per device, but I think it should still be possible to just use one query to get all notifications to send, which would be significantly faster.

rebeccanesson commented 13 years ago

Good point. If you'd like to take a crack at it and submitting a pull request, that would be great. I'll try to take a look as soon as I can.