mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-06 19:42:04 +00:00
Batch SELECTs in _get_auth_chain_ids_txn
This commit is contained in:
parent
2f556e0c55
commit
6924852592
@ -49,14 +49,22 @@ class EventFederationStore(SQLBaseStore):
|
||||
results = set()
|
||||
|
||||
base_sql = (
|
||||
"SELECT auth_id FROM event_auth WHERE event_id = ?"
|
||||
"SELECT auth_id FROM event_auth WHERE event_id IN (%s)"
|
||||
)
|
||||
|
||||
front = set(event_ids)
|
||||
while front:
|
||||
new_front = set()
|
||||
for f in front:
|
||||
txn.execute(base_sql, (f,))
|
||||
front_list = list(front)
|
||||
chunks = [
|
||||
front_list[x:x+100]
|
||||
for x in xrange(0, len(front), 100)
|
||||
]
|
||||
for chunk in chunks:
|
||||
txn.execute(
|
||||
base_sql % (",".join(["?"] * len(chunk)),),
|
||||
chunk
|
||||
)
|
||||
new_front.update([r[0] for r in txn.fetchall()])
|
||||
|
||||
new_front -= results
|
||||
|
Loading…
Reference in New Issue
Block a user