diff --git a/app/lib/patient_status_updater.rb b/app/lib/patient_status_updater.rb index 6d7d948299..a5880585c3 100644 --- a/app/lib/patient_status_updater.rb +++ b/app/lib/patient_status_updater.rb @@ -160,23 +160,4 @@ def programme_types_per_session_id_and_year_group hash[session_id][year_group] << programme_type end end - - # We preload this association separately because including it in the nested - # `patient_locations` preload (see includes above) caused the updater process - # to be killed, even with very small batches. The likely cause is memory pressure - # from eager loading a deeply nested association graph. - # - # Preloading it here for the distinct `Location` records in each batch keeps - # `StatusGenerator::Programme` query-free without incurring the cost of the - # larger nested preload. - def preload_location_programme_year_groups(batch) - locations = batch.flat_map(&:patient_locations).map(&:location).uniq - - ActiveRecord::Associations::Preloader.new( - records: locations, - associations: { - location_programme_year_groups: :location_year_group - } - ).call - end end