Patch #21582
Performance in User#roles_for_project
Status: | Closed | Start date: | ||
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | % Done: | 0% | ||
Category: | Performance | |||
Target version: | 3.3.0 |
Description
roles are duplicating a scope not an result, thus every hit produce a query, cached, but it is still not desired.
Associated revisions
Performance in User#roles_for_project (#21582).
Patch by by Ondřej Ezr.
History
#1
Updated by Go MAEDA about 5 years ago
- Target version set to 3.3.0
I think we can remove the last 'dup' method from Ondřej Ezr's patch because ActiveRecord::Associations::CollectionProxy#to_a returns copied objects.
# File activerecord/lib/active_record/associations/collection_proxy.rb, line 943
def to_ary
load_target.dup
end
#2
Updated by Ondřej Ezr about 5 years ago
true, I just put to_a there with heureka feeling, but you are right dup is meaningless now :)
#3
Updated by Go MAEDA about 5 years ago
Thanks for your feedback. Nice eureka!
#4
Updated by Jean-Philippe Lang about 5 years ago
- Subject changed from Performance in roles to Performance in User#roles_for_project
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
Committed, thanks.