Remove terrible inner table scans for profile lookups.
This commit is contained in:
parent
a2ae886d73
commit
dfd8f70970
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user