mirror of
https://github.com/rommapp/romm.git
synced 2026-06-27 22:35:57 +00:00
get_all_saves() materialized every Save row across all users into a single .all() list. On instances with very large libraries that's a real RAM ceiling and pins every row for the lifetime of the recompute run. Replace it with get_saves_after_id(after_id, limit) and have the recompute task drive keyset pagination in PAGE_SIZE-row chunks. SQLAlchemy streaming via .execution_options(yield_per=...) is incompatible with the per-call session lifetime that @begin_session enforces (the session exits before the consumer iterates), so keyset paging from the caller is the cleanest fit. Behavior is unchanged: same row coverage, same idempotency, same counters. Memory usage drops from O(all saves) to O(PAGE_SIZE).