Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Perf issue with "all" scope #77

Closed
emzeq opened this Issue · 3 comments

4 participants

@emzeq

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

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

@gregbell gregbell was assigned
@Rio517

I was having the same issue.

@pcreux pcreux closed this issue from a commit
Commit has since been removed from the repository and is no longer available.
@pcreux pcreux closed this in 9554ef6
@pcreux pcreux reopened this
@pcreux
Collaborator

Pushed to the wrong repos. :-/

@pcreux pcreux referenced this issue from a commit in pcreux/active_admin
@pcreux pcreux Closes #77. Fix performance issue with scope :all.
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?
e11ebeb
@pcreux pcreux closed this in 89db533
@whatthewhat whatthewhat referenced this issue from a commit in whatthewhat/active_admin
@pcreux pcreux Closes #77. Fix performance issue with scope :all.
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?
b581eaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.