Re: EXPLAIN PLAN for DELETE CASCADE or DELETE not using pkey indexdespite EXPLAINing that it would?

Поиск
Список
Период
Сортировка
От Justin Pryzby
Тема Re: EXPLAIN PLAN for DELETE CASCADE or DELETE not using pkey indexdespite EXPLAINing that it would?
Дата
Msg-id 20190322200719.GR2952@telsasoft.com
обсуждение исходный текст
Ответ на EXPLAIN PLAN for DELETE CASCADE or DELETE not using pkey indexdespite EXPLAINing that it would?  (Gunther <raj@gusw.net>)
Список pgsql-performance
On Thu, Mar 21, 2019 at 03:31:42PM -0400, Gunther wrote:
> Hi,
> 
> I have 250 rows to delete, but they are a target to a bunch of child tables
> with foreign key on delete cascade.
> 
> EXPLAIN DELETE FROM Foo WHERE id = (SELECT fooId FROM Garbage);

Probably because:
https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK
"Since a DELETE of a row from the referenced table [...] will require a scan of
the referencing table for rows matching the old value, it is often a good idea
to index the referencing columns too."

Can you show "\d+ foo", specifically its FKs ?

Justin


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

Предыдущее
От: Gunther
Дата:
Сообщение: Re: EXPLAIN PLAN for DELETE CASCADE or DELETE not using pkey indexdespite EXPLAINing that it would?
Следующее
От: Mariel Cherkassky
Дата:
Сообщение: trying to analyze deadlock