summary refs log tree commit diff
path: root/synapse/storage/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-13 15:26:49 +0100
committerErik Johnston <erik@matrix.org>2015-05-13 15:26:49 +0100
commit5971d240d458dbea23abed803aa3d7bf31c2efce (patch)
tree01faba955e5f8b8dbc1d6516322cab68f75b49d3 /synapse/storage/_base.py
parentFetch events in bulk (diff)
downloadsynapse-5971d240d458dbea23abed803aa3d7bf31c2efce.tar.xz
Limit batch size
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r--synapse/storage/_base.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index f7b4def9ec..f169884d83 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -28,6 +28,7 @@ from twisted.internet import defer
 
 from collections import namedtuple, OrderedDict
 import functools
+import itertools
 import simplejson as json
 import sys
 import time
@@ -875,11 +876,15 @@ class SQLBaseStore(object):
 
     def _get_events_txn(self, txn, event_ids, check_redacted=True,
                         get_prev_content=False):
-        return self._fetch_events_txn(
-            txn, event_ids,
-            check_redacted=check_redacted,
-            get_prev_content=get_prev_content,
-        )
+        N = 50  # Only fetch 100 events at a time.
+        return list(itertools.chain(*[
+            self._fetch_events_txn(
+                txn, event_ids[i*N:(i+1)*N],
+                check_redacted=check_redacted,
+                get_prev_content=get_prev_content,
+            )
+            for i in range(1 + len(event_ids) / N)
+        ]))
 
     def _invalidate_get_event_cache(self, event_id):
         for check_redacted in (False, True):