mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 00:53:52 +01:00
Don't needlessly join on state_events
This commit is contained in:
parent
d89a9f7283
commit
2366d28780
2 changed files with 4 additions and 6 deletions
|
@ -196,14 +196,13 @@ class RoomStore(SQLBaseStore):
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT e.*, (%(redacted)s) AS redacted FROM events as e "
|
"SELECT e.*, (%(redacted)s) AS redacted FROM events as e "
|
||||||
"INNER JOIN current_state_events as c ON e.event_id = c.event_id "
|
"INNER JOIN current_state_events as c ON e.event_id = c.event_id "
|
||||||
"INNER JOIN state_events as s ON e.event_id = s.event_id "
|
|
||||||
"WHERE c.room_id = ? "
|
"WHERE c.room_id = ? "
|
||||||
) % {
|
) % {
|
||||||
"redacted": del_sql,
|
"redacted": del_sql,
|
||||||
}
|
}
|
||||||
|
|
||||||
sql += " AND ((s.type = 'm.room.name' AND s.state_key = '')"
|
sql += " AND ((c.type = 'm.room.name' AND c.state_key = '')"
|
||||||
sql += " OR s.type = 'm.room.aliases')"
|
sql += " OR c.type = 'm.room.aliases')"
|
||||||
args = (room_id,)
|
args = (room_id,)
|
||||||
|
|
||||||
results = yield self._execute_and_decode("get_current_state", sql, *args)
|
results = yield self._execute_and_decode("get_current_state", sql, *args)
|
||||||
|
|
|
@ -136,17 +136,16 @@ class StateStore(SQLBaseStore):
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT e.*, (%(redacted)s) AS redacted FROM events as e "
|
"SELECT e.*, (%(redacted)s) AS redacted FROM events as e "
|
||||||
"INNER JOIN current_state_events as c ON e.event_id = c.event_id "
|
"INNER JOIN current_state_events as c ON e.event_id = c.event_id "
|
||||||
"INNER JOIN state_events as s ON e.event_id = s.event_id "
|
|
||||||
"WHERE c.room_id = ? "
|
"WHERE c.room_id = ? "
|
||||||
) % {
|
) % {
|
||||||
"redacted": del_sql,
|
"redacted": del_sql,
|
||||||
}
|
}
|
||||||
|
|
||||||
if event_type and state_key is not None:
|
if event_type and state_key is not None:
|
||||||
sql += " AND s.type = ? AND s.state_key = ? "
|
sql += " AND c.type = ? AND c.state_key = ? "
|
||||||
args = (room_id, event_type, state_key)
|
args = (room_id, event_type, state_key)
|
||||||
elif event_type:
|
elif event_type:
|
||||||
sql += " AND s.type = ?"
|
sql += " AND c.type = ?"
|
||||||
args = (room_id, event_type)
|
args = (room_id, event_type)
|
||||||
else:
|
else:
|
||||||
args = (room_id, )
|
args = (room_id, )
|
||||||
|
|
Loading…
Reference in a new issue