mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-18 00:43:30 +03:00
In get_recent_events_for_room, get the full event json rather than just the event_ids so we don't have to do so many db queries
This commit is contained in:
parent
33d2d82f6d
commit
03c0da9f65
1 changed files with 14 additions and 7 deletions
|
@ -269,8 +269,11 @@ class StreamStore(SQLBaseStore):
|
||||||
# TODO (erikj): Handle compressed feedback
|
# TODO (erikj): Handle compressed feedback
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT stream_ordering, topological_ordering, event_id FROM events "
|
"SELECT stream_ordering, topological_ordering, "
|
||||||
"WHERE room_id = ? AND stream_ordering <= ? AND outlier = 0 "
|
"internal_metadata, json, r.event_id FROM events as e "
|
||||||
|
"LEFT JOIN event_json as ej ON e.event_id = ej.event_id "
|
||||||
|
"LEFT JOIN redactions as r ON e.event_id = r.redacts "
|
||||||
|
"WHERE e.room_id = ? AND stream_ordering <= ? AND outlier = 0 "
|
||||||
"ORDER BY topological_ordering DESC, stream_ordering DESC LIMIT ? "
|
"ORDER BY topological_ordering DESC, stream_ordering DESC LIMIT ? "
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -295,11 +298,15 @@ class StreamStore(SQLBaseStore):
|
||||||
else:
|
else:
|
||||||
token = (end_token, end_token)
|
token = (end_token, end_token)
|
||||||
|
|
||||||
events = self._get_events_txn(
|
events = [
|
||||||
txn,
|
self._get_event_from_row_txn(
|
||||||
[r["event_id"] for r in rows],
|
txn,
|
||||||
get_prev_content=True
|
r["internal_metadata"],
|
||||||
)
|
r["json"],
|
||||||
|
r["event_id"],
|
||||||
|
)
|
||||||
|
for r in rows
|
||||||
|
]
|
||||||
|
|
||||||
return events, token
|
return events, token
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue