CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Sending emails from Openerp 7 causes 1GB memory spike. This is caused by this part of the code:
fol_obj = self.pool.get("mail.followers")
fol_ids = fol_obj.search(cr, SUPERUSER_ID, [
('res_model', '=', message.model),
('res_id', '=', message.res_id),
('subtype_ids', 'in', message.subtype_id.id)
in /openerp-base/src/addons/mail/mail_message.py (def _notify method line 881).
Our mail_folowers table contains around 3 000 000 rows. The search method, in converting our code example to sql statement, at the point where it creates a where clause, it does a string supstitution something like - "where s%, s%, s%...." with 3 000 000 %s characters, and then substitutes a list of 3 million id elements to create a single string. Than it executes that string. This causes a memory error on our system in /openerp-base/src/server/openerp/tools/misc.py, flatten() method (line 226).
A workaround is to use cr.execute() insted of search method, but I am afraid that this points to a bigger problem. When using tables with more than a couple of million of rows, search is a big problem.
About This Community
Odoo Training Center
|Asked: 7/30/15, 8:53 AM|
|Seen: 680 times|
|Last updated: 7/30/15, 9:35 AM|