{"action":"created","issue":{"url":"https://api.github.com/repos/odoo/odoo/issues/24119","repository_url":"https://api.github.com/repos/odoo/odoo","labels_url":"https://api.github.com/repos/odoo/odoo/issues/24119/labels{/name}","comments_url":"https://api.github.com/repos/odoo/odoo/issues/24119/comments","events_url":"https://api.github.com/repos/odoo/odoo/issues/24119/events","html_url":"https://github.com/odoo/odoo/issues/24119","id":312324216,"number":24119,"title":"[PERF][11.0] access to related field with very bad performance","user":{"login":"fmdl","id":16716992,"avatar_url":"https://avatars2.githubusercontent.com/u/16716992?v=4","gravatar_id":"","url":"https://api.github.com/users/fmdl","html_url":"https://github.com/fmdl","followers_url":"https://api.github.com/users/fmdl/followers","following_url":"https://api.github.com/users/fmdl/following{/other_user}","gists_url":"https://api.github.com/users/fmdl/gists{/gist_id}","starred_url":"https://api.github.com/users/fmdl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fmdl/subscriptions","organizations_url":"https://api.github.com/users/fmdl/orgs","repos_url":"https://api.github.com/users/fmdl/repos","events_url":"https://api.github.com/users/fmdl/events{/privacy}","received_events_url":"https://api.github.com/users/fmdl/received_events","type":"User","site_admin":false},"labels":[{"id":712046675,"url":"https://api.github.com/repos/odoo/odoo/labels/11.0","name":"11.0","color":"80f438","default":false},{"id":616698546,"url":"https://api.github.com/repos/odoo/odoo/labels/Framework","name":"Framework","color":"E5E970","default":false},{"id":814899699,"url":"https://api.github.com/repos/odoo/odoo/labels/Performance","name":"Performance","color":"a1fccd","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-08T17:36:44Z","updated_at":"2018-04-09T10:18:23Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Impacted versions: 11.0 (and maybe more)\r\n\r\nSteps to reproduce:\r\n- create a model : `perf_max`\r\n- create a field : `name`\r\n- create a field computed (or related) and stored : `compute_name`, with depends `name`\r\n- create 2000 record of `perf_max`\r\n- execute :\r\n```\r\ndef stuff(self):\r\n    recs = self.search([]) # get all records\r\n    with self.env.norecompute():\r\n        recs.write({'name':truc})\r\n        for rec in recs:\r\n             print(rec.compute_name)\r\n\r\n     self.recompute()\r\n```\r\n--> it is so long inside the loop. Because \r\n- during the write, alls record are flaged in the `todo recompute list`. And by the fact we are on `norecompute` `env`, the records stay in the `todo recompute list`.\r\n- during the `get('compute_name')` all records are computed each time (by prefech fonction), because after the compute the records are not removed from the `todo recompute list`. \r\nhttps://github.com/odoo/odoo/blob/10.0/odoo/fields.py#L997\r\n\r\nNota : `record._recompute_check(self)` aka https://github.com/odoo/odoo/blob/11.0/odoo/api.py#L878, return all records not updated.\r\n\r\nI think it is not the best idea to use the `todo recompute list` to know if the record is update. When a record go into the `todo recompute list`, those cache are invalided.\r\n\r\nWith this https://github.com/odoo/odoo/pull/24115 or https://github.com/odoo/odoo/pull/24118 (more generic), it could be fix that.\r\n\r\n\r\n@odony @rco-odoo @wtaferner @sylvain-garancher \r\n\r\nFor an importation of 1000 sale.order.line with `env.norecompute` : before 237 secondes, after 89 secondes : - 54%"},"comment":{"url":"https://api.github.com/repos/odoo/odoo/issues/comments/379704750","html_url":"https://github.com/odoo/odoo/issues/24119#issuecomment-379704750","issue_url":"https://api.github.com/repos/odoo/odoo/issues/24119","id":379704750,"user":{"login":"Yenthe666","id":6352350,"avatar_url":"https://avatars3.githubusercontent.com/u/6352350?v=4","gravatar_id":"","url":"https://api.github.com/users/Yenthe666","html_url":"https://github.com/Yenthe666","followers_url":"https://api.github.com/users/Yenthe666/followers","following_url":"https://api.github.com/users/Yenthe666/following{/other_user}","gists_url":"https://api.github.com/users/Yenthe666/gists{/gist_id}","starred_url":"https://api.github.com/users/Yenthe666/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yenthe666/subscriptions","organizations_url":"https://api.github.com/users/Yenthe666/orgs","repos_url":"https://api.github.com/users/Yenthe666/repos","events_url":"https://api.github.com/users/Yenthe666/events{/privacy}","received_events_url":"https://api.github.com/users/Yenthe666/received_events","type":"User","site_admin":false},"created_at":"2018-04-09T10:18:22Z","updated_at":"2018-04-09T10:18:22Z","author_association":"CONTRIBUTOR","body":"@xmo-odoo for your interest."}}
{"actor":{"display_login":"Yenthe666"}}