Skip to content

A platform for community discussion. Free, open, simple.

PERF: Scanning the `id` for this is signficantly slower in production

Robin Ward5d1d7e0e7d75
diff --git a/app/models/user.rb b/app/models/user.rb
index 816ed33f7fe..58709059dad 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -449,7 +449,7 @@ class User < ActiveRecord::Base
def publish_notifications_state
# publish last notification json with the message so we can apply an update
- notification = notifications.visible.order('notifications.id desc').first
+ notification = notifications.visible.order('notifications.created_at desc').first
json = NotificationSerializer.new(notification).as_json if notification
sql = (<<~SQL).freeze