changeset f4ea454f5131 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=f4ea454f5131
description:
Skip eager loading if field is already in the cache
The Many2One and Reference fields are stored in global cache. If they
are
already in the cache, the other eager fields should also be in the
cache and it
is highly probable that no read will be needed. So it is better to skip
the
eager loading.
issue8863
review272541003
diffstat:
trytond/model/modelstorage.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diffs (22 lines):
diff -r cfa74dc611b4 -r f4ea454f5131 trytond/model/modelstorage.py
--- a/trytond/model/modelstorage.py Wed Dec 11 18:43:27 2019 +0100
+++ b/trytond/model/modelstorage.py Wed Dec 11 22:19:04 2019 +0100
@@ -1421,14 +1421,16 @@
try:
if field._type not in ('many2one', 'reference'):
return self._cache[self.id][name]
+ else:
+ skip_eager = name in self._cache[self.id]
except KeyError:
- pass
+ skip_eager = False
# build the list of fields we will fetch
ffields = {
name: field,
}
- if field.loading == 'eager':
+ if field.loading == 'eager' and not skip_eager:
FieldAccess = Pool().get('ir.model.field.access')
fread_accesses = {}
fread_accesses.update(FieldAccess.check(self.__name__,