Vauxoo / odoo

Fork of Odoo (formerly OpenERP). [This project is not publically mantained just born for internal usage with some little patches] go to official repository on github.com/odoo/odoo
https://www.odoo.com
Other
9 stars 9 forks source link

[REF] website: Speedup website (when a theme is installed) #381

Closed WR-96 closed 3 years ago

WR-96 commented 3 years ago

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:

    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

Desired behavior after PR is merged:

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