Re: Extremely slow DELETE with cascade foreign keys - Mailing list pgsql-performance

From Rodrigo Rosenfeld Rosas
Subject Re: Extremely slow DELETE with cascade foreign keys
Date
Msg-id 3c0737b6-091b-9de4-7d7a-51f78544fc0d@gmail.com
Whole thread Raw
In response to Re: Extremely slow DELETE with cascade foreign keys  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-performance
Em 05-12-2017 14:43, Alvaro Herrera escreveu:
> Rodrigo Rosenfeld Rosas wrote:
>
>> explain analyze delete from field_values where transaction_id=226;
>> QUERY PLAN
>>
---------------------------------------------------------------------------------------------------------------------------------------------------------------
>>   Delete on field_values  (cost=0.43..257.93 rows=481 width=6) (actual
>> time=367375.805..367375.805 rows=0 loops=1)
>>     ->  Index Scan using index_field_values_on_transaction_id on
>> field_values  (cost=0.43..257.93 rows=481 width=6) (actual time=0.223..4.216
>> rows=651 loops=1)
>>           Index Cond: (transaction_id = 226)
>>   Planning time: 0.234 ms
>>   Execution time: 367375.882 ms
>> (5 registros)
>>
>> Time: 367377,085 ms (06:07,377)
> Normally this is because you lack indexes on the referencing columns, so
> the query that scans the table to find the referencing rows is a
> seqscan.
>

Thank you, Álvaro, that was indeed the case, just like Tom Lane 
suggested as well. I found the missing index and fixed it. Thanks :)



pgsql-performance by date:

Previous
From: Rodrigo Rosenfeld Rosas
Date:
Subject: Re: Extremely slow DELETE with cascade foreign keys
Next
From: Tom Lane
Date:
Subject: Re: Extremely slow DELETE with cascade foreign keys