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

Perf issue with "all" scope #77

Closed
emzeq opened this issue May 21, 2011 · 3 comments
Closed

Perf issue with "all" scope #77

emzeq opened this issue May 21, 2011 · 3 comments
Assignees
Milestone

Comments

@emzeq
Copy link
Contributor

emzeq commented May 21, 2011

I was doing some perf testing and found this issue.

activeadmin-demo/admin/products.rb in your activeadmin-demo project:
line 3: scope :all, :default => true

Adding the "all" scope causes a full table read on the following line:
active_admin/views/components/scopes.rb:
line 52: scoping_class.send(scope.scope_method).count

The perf here gets really bad after a few thousand records.

@emzeq
Copy link
Contributor Author

emzeq commented May 22, 2011

Here's a workaround:
https://gist.github.com/985758

@ghost ghost assigned gregbell May 24, 2011
@Rio517
Copy link

Rio517 commented Jul 25, 2011

I was having the same issue.

@pcreux pcreux closed this as completed Aug 6, 2011
@pcreux pcreux reopened this Aug 6, 2011
@pcreux
Copy link
Contributor

pcreux commented Aug 6, 2011

Pushed to the wrong repos. :-/

pcreux added a commit to pcreux/active_admin that referenced this issue Aug 6, 2011
Scope :all does not call :all on the relation anymore but returns
the ActiveRecord class instead.

Moved the logic scoping the scope into a helper called ScopeChain.

I wanted to implement this method on the Scope class itself but that
runs the scoping block in the Scope instance context instead of the
ResourceController one.

This method is both used in the ResourceController and the
ViewHelper Scopes.

@gregbell: Could we share this method without creating a new
helper?
@pcreux pcreux closed this as completed in 89db533 Aug 11, 2011
whatthewhat pushed a commit to whatthewhat/active_admin that referenced this issue Aug 13, 2011
Scope :all does not call :all on the relation anymore but returns
the ActiveRecord class instead.

Moved the logic scoping the scope into a helper called ScopeChain.

I wanted to implement this method on the Scope class itself but that
runs the scoping block in the Scope instance context instead of the
ResourceController one.

This method is both used in the ResourceController and the
ViewHelper Scopes.

@gregbell: Could we share this method without creating a new
helper?
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