Improve join on platforms in queries on roms table

The old variant added subqueries that query the entire rom table which
were evaluated for each rom, absolutely tanking the performance on
larger collections.
This commit is contained in:
Michon van Dooren committed 2025-12-29 21:25:55 +01:00
1 parent 6bd6264f7e
commit dfd8840f97
1 file changed
+2 -2
+2 -2
View File
@@ -106,7 +106,7 @@ def with_details(func):
def wrapper(*args, **kwargs):
kwargs["query"] = select(Rom).options(
# Ensure platform is loaded for main ROM objects
joinedload(Rom.platform),
selectinload(Rom.platform),
selectinload(Rom.saves).options(
noload(Save.rom),
noload(Save.user),
@@ -138,7 +138,7 @@ def with_simple(func):
def wrapper(*args, **kwargs):
kwargs["query"] = select(Rom).options(
# Ensure platform is loaded for main ROM objects
joinedload(Rom.platform),
selectinload(Rom.platform),
# Display properties for the current user (last_played)
selectinload(Rom.rom_users).options(noload(RomUser.rom)),
# Sort table by metadata (first_release_date)