[FIX] account_financial_report: Avoid slow vacuum due to ondelete=cascade

`report_journal_ledger` is auto-vacuumed as any transient model, but has some
ondelete="cascade" constraints that auto-remove subtables when a record is removed,
doing this operation very slow when selecting these sub-records.

Letting default ondelete="set null" would result in same performance bottleneck,
as the select on sub-table is performed the same for setting "null" value on them.

As a solution, and for avoiding a costly index operation, we delete by SQL sub-tables
rows in advance.

A bit of extra logic has been added for avoiding to remove that records if it's not
the turn of vacuum the parent table.
This commit is contained in:
Pedro M. Baeza
2019-08-17 20:25:18 +02:00
committed by chaule97
parent 091a3f31ad
commit 1dbf6b19bd
5 changed files with 27 additions and 1 deletions

View File

@@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Account Financial Reports',
'version': '12.0.1.2.1',
'version': '12.0.1.2.2',
'category': 'Reporting',
'summary': 'OCA Financial Reports',
'author': 'Camptocamp SA,'