Perf: Volunteer edit - GET /volunteers/:id/edit
trace-volunteers-edit-2023-01-17T204629_0100.log
GET /volunteers/1855/edit
params:
controller: volunteers
action: edit
id: '1855'
duration: 1.305161
Total allocated: 647.86 MB (1075908 objects)
Total retained: 23.85 MB (46115 objects)
Speed could be improved by doing .eager_load
in the volunteers_controller
def set_volunteer
v_scope = Volunteer.eager_load(group_assignments: [:trial_period, :group_offer])
.eager_load(:group_assignment_logs)
.eager_load(:assignment_logs)
.eager_load(
assignments: [
:trial_period,
client: [:contact,
involved_authority: [profile: [:contact]]],
creator: [profile: [:contact]]
]
)
.eager_load(:contact)
.eager_load(:relatives)
.eager_load(:group_offer_categories)
.eager_load(:language_skills)
if current_user.superadmin?
v_scope = v_scope.eager_load(invited_by: [profile: [:contact]])
.eager_load(accepted_by: [profile: [:contact]])
.eager_load(undecided_by: [profile: [:contact]])
.eager_load(rejected_by: [profile: [:contact]])
.eager_load(resigned_by: [profile: [:contact]])
end
@volunteer = v_scope.find(params[:id])
authorize @volunteer
end
The memory trace with this and some template fixes is:
trace-volunteers-edit-2023-01-18T113246_0100.log
GET /volunteers/556/edit
params:
controller: volunteers
action: edit
id: '556'
duration: 0.88495
Total allocated: 553.58 MB (428570 objects)
Total retained: 2.74 MB (18512 objects)
Edited by Kaspar Vollenweider