From 26b4dbde417cd2c35871f23ff93f46ac1e5c9847 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Fri, 26 Apr 2019 22:26:31 +1000 Subject: [PATCH] PERF: use delete_all to remove notifications and topic_users Previously we used destroy here which could be extremely expensive --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index f26ac53661f..0b11dfee0d7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -22,8 +22,8 @@ class User < ActiveRecord::Base include HasDestroyedWebHook has_many :posts - has_many :notifications, dependent: :destroy - has_many :topic_users, dependent: :destroy + has_many :notifications, dependent: :delete_all + has_many :topic_users, dependent: :delete_all has_many :category_users, dependent: :destroy has_many :tag_users, dependent: :destroy has_many :user_api_keys, dependent: :destroy