Closed WR-96 closed 3 years ago
After install a website theme the webpage is slower
It is because a new query is executed to get website attachments (1)
This query is so slow and it is executed each time the website is opened
Running the following query:
EXPLAIN (ANALYZE, VERBOSE, BUFFERS) SELECT id FROM ir_attachment WHERE active=True AND key = 'SOMETHING' AND website=1
The result before index:
Seq Scan on ir_attachment ... Execution Time: 21.320 ms
The result after index (key, website):
Bitmap Heap Scan on ir_attachment ... Execution Time: 0.111 ms
192x faster
The website must be as fast as possible so this index make sense
(1) https://github.com/odoo/odoo/blob/d00a832952a0b9d2276a1f057ee10152b0c7f5bc/addons/website/models/ir_http.py#L332
-- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Description of the issue/feature this PR addresses:
After install a website theme the webpage is slower
It is because a new query is executed to get website attachments (1)
This query is so slow and it is executed each time the website is opened
Current behavior before PR:
Running the following query:
The result before index:
Desired behavior after PR is merged:
The result after index (key, website):
192x faster
The website must be as fast as possible so this index make sense
(1) https://github.com/odoo/odoo/blob/d00a832952a0b9d2276a1f057ee10152b0c7f5bc/addons/website/models/ir_http.py#L332
-- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr