1
0
mirror of synced 2024-11-12 01:00:46 +01:00

Remove terrible inner table scans for profile lookups.

This commit is contained in:
Jennifer Taylor 2023-03-19 16:48:14 +00:00
parent a2ae886d73
commit dfd8f70970

View File

@ -575,7 +575,12 @@ class UserData(BaseData):
"""
if not userids:
return []
sql = "SELECT version, userid FROM refid WHERE game = :game AND userid IN :userids AND refid IN (SELECT refid FROM profile)"
sql = """
SELECT refid.version AS version, refid.userid AS userid
FROM refid
INNER JOIN profile ON refid.refid = profile.refid
WHERE refid.game = :game AND refid.userid IN :userids
"""
cursor = self.execute(sql, {"game": game.value, "userids": userids})
profilever: Dict[UserID, int] = {}
@ -617,7 +622,12 @@ class UserData(BaseData):
Returns:
A List of Tuples of game, version for each game/version the user has played.
"""
sql = "SELECT game, version FROM refid WHERE userid = :userid AND refid IN (SELECT refid FROM profile)"
sql = """
SELECT refid.game AS game, refid.version AS version
FROM refid
INNER JOIN profile ON refid.refid = profile.refid
WHERE refid.userid = :userid
"""
vals: Dict[str, Any] = {"userid": userid}
if game is not None: