Re: Tips on troubleshooting slow DELETE (suspect cascades)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Tips on troubleshooting slow DELETE (suspect cascades)
Дата
Msg-id 1905752.1705443374@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Tips on troubleshooting slow DELETE (suspect cascades)  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Tips on troubleshooting slow DELETE (suspect cascades)
Список pgsql-general
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 1/16/24 09:45, Jim Vanns wrote:
>> I have a slow (CPU bound) DELETE statement I'm attempting to debug and I 
>> suspect that its actually the ON DELETE CASCADE on the foreign key thats 
>> causing it.

99% of the time, the cause is lack of an index on the foreign key's
referencing columns.  We make you have a unique index on the
referenced columns, because otherwise the FK constraint's semantics
are unclear.  But you're not required to make one on the other side.

>> What I need is a way to see into this statement as it executes to 
>> confirm my suspicion - does anyone have any tips on that?

> Explain:
> https://www.postgresql.org/docs/current/sql-explain.html

Specifically, if EXPLAIN ANALYZE shows a lot of time spent in the
enforcement trigger for the FK, this is likely what's happening.

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: hector vass
Дата:
Сообщение: Re: Mimic ALIAS in Postgresql?
Следующее
От: Rob Sargent
Дата:
Сообщение: Re: Mimic ALIAS in Postgresql?