summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorLoan (lse) <lse@odoo.com>2020-10-15 13:32:30 +0000
committerLoan (lse) <lse@odoo.com>2020-10-15 17:04:28 +0000
commitbe1b2d4f4c6bd7c78cbc51e7fadeac51f38e9194 (patch)
treed199e750f70e9c7d7efc40246ffb886242f7b96e /odoo
parent052c524d7868ea683038d18a22022658abb0511c (diff)
[FIX] models.py: performance on filtered_domain on big recordset
Performance issue arise when the recordset is very large due to the union operator which apply at worst `len(self)` times. By storing the ids then browse on them we avoid the union operation execution. PySpy: https://drive.google.com/file/d/1jnxuSWGf2WmqeRz7zQOpBpmeRE5YnTwS/view?usp=sharing filtered_domain (odoo/models.py:5398) take 65.6% of the graph (55.7% of the 85% of button_confirm) To confirm a RFQ with 10 000 of the same product: Before this commit: ~42s After this commit: ~10s OPW-2347525 closes odoo/odoo#60130 X-original-commit: 8b0eeb5076ed5387ca7132d79182800e10c6895e Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo')
-rw-r--r--odoo/models.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/odoo/models.py b/odoo/models.py
index 0150fd6ee01..3046759eaa7 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -5264,7 +5264,7 @@ Fields:
model = model[fname]
if comparator in ('like', 'ilike', '=like', '=ilike', 'not ilike', 'not like'):
value_esc = value.replace('_', '?').replace('%', '*').replace('[', '?')
- records = self.browse()
+ records_ids = set()
for rec in self:
data = rec.mapped(key)
if comparator in ('child_of', 'parent_of'):
@@ -5328,8 +5328,9 @@ Fields:
ok = bool(fnmatch.filter(data, value and value_esc.lower()))
else:
raise ValueError
- if ok: records |= rec
- result.append(records)
+ if ok:
+ records_ids.add(rec.id)
+ result.append(self.browse(records_ids))
while len(result)>1:
result.append(result.pop() & result.pop())
return result[0]