Skip to content

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

PERF: add index on user auth tokens (for user lookups)

Sam Saffronb8c65cc6cfdb
diff --git a/app/models/user_auth_token.rb b/app/models/user_auth_token.rb
index d79bdac31ee..30a38c68bc1 100644
--- a/app/models/user_auth_token.rb
+++ b/app/models/user_auth_token.rb
@@ -242,4 +242,5 @@ end
#
# index_user_auth_tokens_on_auth_token (auth_token) UNIQUE
# index_user_auth_tokens_on_prev_auth_token (prev_auth_token) UNIQUE
+# index_user_auth_tokens_on_user_id (user_id)
#
diff --git a/db/migrate/20190426123658_add_index_on_user_auth_token_user.rb b/db/migrate/20190426123658_add_index_on_user_auth_token_user.rb
new file mode 100644
index 00000000000..7f0a0501a0d
--- /dev/null
+++ b/db/migrate/20190426123658_add_index_on_user_auth_token_user.rb
@@ -0,0 +1,5 @@
+class AddIndexOnUserAuthTokenUser < ActiveRecord::Migration[5.2]
+ def change
+ add_index :user_auth_tokens, [:user_id]
+ end
+end