Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add users remember_token index #11881

Merged
merged 1 commit into from
Sep 18, 2019

Conversation

abcang
Copy link
Contributor

@abcang abcang commented Sep 18, 2019

If remember_token is nil and devise remember_me is executed, generate remember token and run SQL to check if it is unique.

SELECT  "users".* FROM "users" WHERE "users"."remember_token" = 'xxxxx' ORDER BY "users"."id" ASC LIMIT 1

https://github.com/plataformatec/devise/blob/v4.7.1/lib/devise/models/rememberable.rb#L150

However, remember_token has no index, so the more users, the longer it takes to check. This problem happens when logging in for the first time and after logging out. Adding an index to remember_token prevents it from slowing down.

@Gargron Gargron merged commit 0e63907 into mastodon:master Sep 18, 2019
@abcang abcang deleted the add_remember_token_index branch September 18, 2019 09:41
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants