Skip to content
Snippets Groups Projects
Commit 29a9cf98 authored by Denis Ledoux's avatar Denis Ledoux
Browse files

[FIX] account: speeds up `account.payment` deletion


The deletion of `account.payment` were slowed down
because of the missing index

```
                                                                                  QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Delete on account_payment  (cost=20.37..44.45 rows=10 width=34) (actual time=0.449..0.450 rows=0 loops=1)
   ->  Nested Loop  (cost=20.37..44.45 rows=10 width=34) (actual time=0.383..0.404 rows=10 loops=1)
         ->  HashAggregate  (cost=19.95..20.05 rows=10 width=32) (actual time=0.378..0.380 rows=10 loops=1)
               Group Key: "ANY_subquery".id
               Batches: 1  Memory Usage: 24kB
               ->  Subquery Scan on "ANY_subquery"  (cost=0.42..19.92 rows=10 width=32) (actual time=0.035..0.371 rows=10 loops=1)
                     ->  Limit  (cost=0.42..19.82 rows=10 width=4) (actual time=0.032..0.365 rows=10 loops=1)
                           ->  Nested Loop  (cost=0.42..186848.76 rows=96312 width=4) (actual time=0.031..0.364 rows=10 loops=1)
                                 ->  Seq Scan on account_payment_pre_backup pay_backup  (cost=0.00..14763.48 rows=277317 width=4) (actual time=0.015..0.086 rows=53 loops=1)
                                       Filter: ((state)::text <> ALL ('{draft,cancelled}'::text[]))
                                       Rows Removed by Filter: 166
                                 ->  Index Scan using account_payment_pkey on account_payment pay  (cost=0.42..0.62 rows=1 width=4) (actual time=0.005..0.005 rows=0 loops=53)
                                       Index Cond: (id = pay_backup.id)
                                       Filter: (move_id IS NULL)
                                       Rows Removed by Filter: 1
         ->  Index Scan using account_payment_pkey on account_payment  (cost=0.42..2.44 rows=1 width=10) (actual time=0.002..0.002 rows=1 loops=10)
               Index Cond: (id = "ANY_subquery".id)
 Planning Time: 0.294 ms
 Trigger for constraint account_move_line_payment_id_fkey: time=1.236 calls=10
 Trigger for constraint account_payment_sale_order_rel_account_payment_id_fkey: time=0.195 calls=10
 Trigger for constraint credit_token_payment_id_fkey: time=1.308 calls=10
 Trigger for constraint payment_transaction_payment_id_fkey: time=0.288 calls=10
 Trigger for constraint account_invoice_payment_rel_payment_id_fkey1: time=0.191 calls=10
 Trigger for constraint account_move_payment_id_fkey: time=6015.799 calls=10
 Trigger for constraint account_payment_account_bank_statement__account_payment_id_fkey: time=0.444 calls=10
 Execution Time: 6019.988 ms
```

upg-12139

closes odoo/odoo#70712

Signed-off-by: default avatarDenis Ledoux (dle) <dle@odoo.com>
parent 23f95f05
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment