Files
odoo_source/addons/web_editor/models
Samuel Degueldre 2e81f53a2a [FIX] web_editor: add index on original_id to improve delete performance
In #45174, the original_id field was added on ir.attachment, so that
derived images in the web-editor (cropped, resized, optimized, ...)
could keep a trace of the original, such that if the user wanted to
revert it or change the crop/size/optimization parameter, we could do it
from the original again so that for example the quality can be increased
or the crop region made bigger.

The addition of this self-referencing many2one from ir.attachment to
itself however will cause DELETE queries on ir.attachment to do a
sequential scan on the table to update potential records referencing the
deleted record in their original_id field. As the ir.attachment table
tends to be one of the biggest tables in production databases (millions
of records), this scan can take multiple seconds per DELETE operation,
and since attachments are used everywhere in odoo to represent files,
DELETE operations on them are frequent.

Adding an index on the original_id field should make these DELETE
operations substantially faster (scaling with the log of the number of
filled original_id fields, which will be very small, instead of scaling
linearly with number of records)

closes odoo/odoo#54676

X-original-commit: 2b5064a00b7a5c8dc66429869287386f244b1257
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-07-17 13:31:22 +00:00
..