Read at most cache size or IN_MAX records from the database

issue11468
review427111003
This commit is contained in:
Nicolas Évrard
2022-05-10 15:24:37 +02:00
parent dd0b32a107
commit 7e4150ca3f
+5 -3
View File
@@ -1676,11 +1676,13 @@ class ModelStorage(Model):
if id_ not in s:
s.add(id_)
yield id_
read_size = max(1, min(
self._cache.size_limit, self._local_cache.size_limit,
self._transaction.database.IN_MAX))
index = self._ids.index(self.id)
ids = chain(islice(self._ids, index, None),
islice(self._ids, 0, max(index - 1, 0)))
ids = islice(unique(filter(filter_, ids)),
self._transaction.database.IN_MAX)
ids = islice(unique(filter(filter_, ids)), read_size)
def instantiate(field, value, data):
if field._type in ('many2one', 'one2one', 'reference'):
@@ -1744,7 +1746,7 @@ class ModelStorage(Model):
read_data = []
for id_ in islice(chain(islice(self._ids, index, None),
islice(self._ids, 0, max(index - 1, 0))),
self._transaction.database.IN_MAX):
read_size):
if id_ in self._cache:
data = {'id': id_}
for fname in ffields: