Re: deleting rows with foreign keys - Mailing list pgsql-general

From Tom Lane
Subject Re: deleting rows with foreign keys
Date
Msg-id 4596.1184196267@sss.pgh.pa.us
Whole thread Raw
In response to deleting rows with foreign keys  (Tom Allison <tom@tacocat.net>)
List pgsql-general
Tom Allison <tom@tacocat.net> writes:
> I have ~250K rows in this table.
> the token_idx is referenced in two other tables, both of whom have a
> foreign key constraint to ON DELETE CASCADE.
> Of the other two tables, one has ~1M rows and the other ~350K rows.

> Problem:
> Deleting one row can take 2 seconds.

> Is there something I can do to improve the speed.

Put indexes on the referencing columns.  Without that, a seqscan is
required to look for referencing rows.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Allison
Date:
Subject: deleting rows with foreign keys
Next
From: alexander lunyov
Date:
Subject: Re: russian case-insensitive regexp search not working