Don't fetch redaction and rejection stuff for each event, so we can use index only scan

This commit is contained in:
Erik Johnston 2015-05-13 14:39:05 +01:00
parent 02590c3e1d
commit 6edff11a88
2 changed files with 24 additions and 6 deletions

View file

@ -85,8 +85,10 @@ class StateStore(SQLBaseStore):
def fetch_events(txn, events):
sql = (
"SELECT e.internal_metadata, e.json "
"SELECT e.internal_metadata, e.json, r.redacts, rej.event_id "
" FROM event_json as e"
" LEFT JOIN rejections as rej USING (event_id)"
" LEFT JOIN redactions as r ON e.event_id = r.redacts"
" WHERE e.event_id IN (%s)"
) % (",".join(["?"]*len(events)),)
@ -95,7 +97,8 @@ class StateStore(SQLBaseStore):
return [
self._get_event_from_row_txn(
txn, row[0], row[1], None
txn, row[0], row[1], row[2],
rejected_reason=row[3],
)
for row in rows
]