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

switch takes ages #72

Closed
gshilin opened this issue Apr 28, 2015 · 6 comments
Closed

switch takes ages #72

gshilin opened this issue Apr 28, 2015 · 6 comments

Comments

@gshilin
Copy link

gshilin commented Apr 28, 2015

I've got around 400,000 users and switch takes ages.
It also tries to load all of these users into memory.
Any ideas?

@sergey-alekseev
Copy link
Contributor

@gshilin have you encountered memory issues like Cannot allocate memory - identify?

@flyerhzm
Copy link
Owner

@gshilin @sergey-alekseev on README, I mentioned "If there are too many users (on production), the switch_user_select is not a good choice, you should call the switch user request by yourself.", you can build an input text field, fuzzy search users by ajax, then call the switch user request.

@gshilin
Copy link
Author

gshilin commented May 12, 2015

I don't use switch_user_select. The problem is in switch_user_controller#handle_request where the following line

record = SwitchUser.data_sources.find_scope_id(params[:scope_identifier])

loads ALL users.
I'm on Rails 4.2 and ruby 2.2.2

@Whitespace
Copy link

+1, this generates a SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL for us

flyerhzm added a commit that referenced this issue Jun 20, 2015
SwitchUser.all_users only selects identifier and name columns.
SwitchUser.find_scope_id only queries that user.
flyerhzm added a commit that referenced this issue Jun 20, 2015
SwitchUser.all_users only selects identifier and name columns.
SwitchUser.data_sources.find_scope_id only queries that user.
@flyerhzm
Copy link
Owner

it should already be fixed in master branch, could you try it?

@gshilin
Copy link
Author

gshilin commented Jun 22, 2015

Yes, it works now, thank you

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

No branches or pull requests

4 participants