From 5d1d7e0e7d7515507a447d443ead8f427c9c393a Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 28 Jun 2018 11:04:40 -0400 Subject: [PATCH] PERF: Scanning the `id` for this is signficantly slower in production --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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