[FIX] web: faster asset search
Help postgres planner avoiding a scan over the entire table. On a database with 5.5M ir_attachment but only a few url: before: https://explain.dalibo.com/plan/g45f7492a78d6e19#raw after: https://explain.dalibo.com/plan/1f5868ba6909b5df#raw from 1156.316 ms to 2.334 ms opw-3134913 closes odoo/odoo#113389 X-original-commit: 1549c4dc81f1f5f327b9115944faa87255c31624 Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
This commit is contained in:
@@ -90,10 +90,11 @@ class Binary(http.Controller):
|
||||
# pylint: disable=redefined-builtin,invalid-name
|
||||
def content_assets(self, id=None, filename=None, unique=False, extra=None, nocache=False):
|
||||
if not id:
|
||||
domain = [('url', '!=', False)]
|
||||
if extra:
|
||||
domain = [('url', '=like', f'/web/assets/%/{extra}/{filename}')]
|
||||
domain += [('url', '=like', f'/web/assets/%/{extra}/{filename}')]
|
||||
else:
|
||||
domain = [
|
||||
domain += [
|
||||
('url', '=like', f'/web/assets/%/{filename}'),
|
||||
('url', 'not like', f'/web/assets/%/%/{filename}')
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user