[FIX] export time regression by b5c660d8
While c059e7b93c64b9dd9bc96eeb6ee5cadf significantly lowers the cost of generating xids, a safety invalidate cache can regress cases significantly e.g. 18s -> 430s (7mn) for some recursive exports of xids as the cache would be completely cleared *after each record* requiring complete fetching & recomputation of the following records. Fix by only clearing the cache if we've actually had to create xids *and* only for ir.model.data records. It's possible that clearing the cache isn't even necessary at all (?), check with @rco-odoo OPW-1835226
This commit is contained in:
+9
-3
@@ -650,6 +650,12 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
|
||||
|
||||
# create missing xml ids
|
||||
missing = self.filtered(lambda r: r.id not in xids)
|
||||
if not missing:
|
||||
return (
|
||||
(record, '%s.%s' % xids[record.id])
|
||||
for record in self
|
||||
)
|
||||
|
||||
xids.update(
|
||||
(r.id, (modname, '%s_%s_%s' % (
|
||||
r._table,
|
||||
@@ -658,6 +664,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
|
||||
)))
|
||||
for r in missing
|
||||
)
|
||||
fields = ['module', 'model', 'name', 'res_id']
|
||||
cr.copy_from(io.StringIO(
|
||||
u'\n'.join(
|
||||
u"%s\t%s\t%s\t%d" % (
|
||||
@@ -669,10 +676,9 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
|
||||
for record in missing
|
||||
)),
|
||||
table='ir_model_data',
|
||||
columns=['module', 'model', 'name', 'res_id'],
|
||||
columns=fields,
|
||||
)
|
||||
|
||||
self.invalidate_cache()
|
||||
self.env['ir.model.data'].invalidate_cache(fnames=fields)
|
||||
|
||||
return (
|
||||
(record, '%s.%s' % xids[record.id])
|
||||
|
||||
Reference in New Issue
Block a user