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

Index user.random_slugs #32

Open
awm33 opened this issue Oct 9, 2016 · 2 comments
Open

Index user.random_slugs #32

awm33 opened this issue Oct 9, 2016 · 2 comments

Comments

@awm33
Copy link
Member

awm33 commented Oct 9, 2016

The user.random_slugs field is searched every time a request authenticates a user. Because that operation is run so often, this field should be indexed. The field is a postgres array type, an array of strings. It looks like the best way to index this is using gin.

This currently uses the __contains operation built into django. Will operation take advantage of an index? If not, we need to somehow use one that will, even if it means passing raw SQL. Most querysets (all?) expose a query property that can be used to see what sql was run, passing this to EXPLAIN in postgres will tell you if the index is being used.

@awm33 awm33 added the task label Oct 9, 2016
@dcgoss
Copy link
Member

dcgoss commented Jun 27, 2017

I would like to clear up some confusion I have about the random_slugs field. I completely understand its use in "authenticating" a user, however I am confused about why it is an array. Why are there multiple random_slugs? And even if there are, could you just store the "authentication" slug in its own field and then index that directly?

@bdolly
Copy link
Member

bdolly commented Jun 27, 2017

@awm made that filed an array in case a user accidentally created 2 accounts they could easily be merged into the array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants