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

2019-03-22 Thread Justin Pryzby
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/do

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

2019-03-22 Thread Gunther
On 3/21/2019 17:16, Tom Lane wrote: Gunther writes: 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); shows me that it uses the nested loop by Foo_pkey index to find t

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

2019-03-21 Thread Tom Lane
Gunther writes: > 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); > shows me that it uses the nested loop by Foo_pkey index to find the 250 > items from Garbage t

EXPLAIN PLAN for DELETE CASCADE or DELETE not using pkey index despite EXPLAINing that it would?

2019-03-21 Thread Gunther
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); shows me that it uses the nested loop by Foo_pkey index to find the 250 items from Garbage to be deleted. But