From 1f062ae2fde43a44f407f4af91a190c8c02fb1e0 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 Feb 2016 18:54:53 +1100 Subject: [PATCH] PERF: improve performance of consistency query --- app/models/category_user.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/category_user.rb b/app/models/category_user.rb index e7138d91da6..7f0ab17a885 100644 --- a/app/models/category_user.rb +++ b/app/models/category_user.rb @@ -95,7 +95,14 @@ class CategoryUser < ActiveRecord::Base end def self.ensure_consistency! - exec_sql("DELETE FROM category_users WHERE user_id NOT IN (SELECT id FROM users)") + exec_sql <