GetListeningHistory used AsEnumerable() before DistinctBy/Take, which forced EF Core to materialize every history row for the user just to keep the last 15 distinct tracks. Now groups by track and takes the 15 most recently played track ids in SQL, then fetches only those.