** Also affects: ocb-addons Importance: Undecided Status: New ** Also affects: ocb-addons/7.0 Importance: Undecided Status: New
-- You received this bug notification because you are a member of OpenERP Community Backports, which is subscribed to OpenERP Community Backports (Addons). https://bugs.launchpad.net/bugs/1311087 Title: mail: 'Send a message' generates excessively slow queries Status in OpenERP Community Backports (Addons): New Status in OpenERP Community Backports (Addons) 7.0 series: New Status in Odoo Addons: New Bug description: Using the "Send a message" action on a model having a mail.thread, I notice a very long delay (8-10 seconds) before the action is done. I used the debug_sql log level and could see that this slowness is due to the queries generated by the ORM. In the `mail_message` module, in `mail_message._notify`, we can see this query: fol_ids = fol_obj.search(cr, SUPERUSER_ID, [ ('res_model', '=', message.model), ('res_id', '=', message.res_id), ('subtype_ids', 'in', message.subtype_id.id) ], context=context) Which results in: 2014-04-22 14:00:05 CEST LOG: duration: 1138.682 ms statement: SELECT "mail_followers_id" FROM "mail_followers_mail_message_subtype_rel" WHERE "mail_message_subtype_id" IN (1) 2014-04-22 14:00:21 CEST LOG: duration: 2544.561 ms statement: SELECT "mail_followers".id FROM "mail_followers" WHERE ((("mail_followers"."res_model" = 'crm.claim') AND ("mail_followers"."res_id" = 894)) AND ("mail_followers"."id" in (1,2,3,4,5, .....))) ORDER BY "mail_followers"."id" where (1,2,3,4,5, .....) contains the IDs returned by the first statement (2.500.000 ids here). Same result could be done with a query using JOINs: SELECT mail_followers.id FROM mail_followers INNER JOIN mail_followers_mail_message_subtype_rel rel ON rel.mail_followers_id = mail_followers.id WHERE mail_followers.res_model = 'crm.claim' AND mail_followers.res_id = 894 AND rel.mail_message_subtype_id = 1 ORDER BY mail_followers.id Then, it takes merely a millisecond instead of several seconds. To manage notifications about this bug go to: https://bugs.launchpad.net/ocb-addons/+bug/1311087/+subscriptions -- Mailing list: https://launchpad.net/~openerp-community-reviewer Post to : openerp-community-reviewer@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-community-reviewer More help : https://help.launchpad.net/ListHelp