Re: Extremely Slow Cascade Delete Operation

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Yan Cheng Cheok <yccheok(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Extremely Slow Cascade Delete Operation
Date: 2010-01-13 11:01:40
Message-ID: 4B4DA814.9050006@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 13/01/2010 4:09 PM, Yan Cheng Cheok wrote:
> I have 3 tables - lot, unit and measurement
>
> 1 lot is having relationship to many unit.
> 1 unit is having relationship to many measurement.
> delete cascade is being used among their relationship
>

> SemiconductorInspection=# delete from lot where lot_id = 2;

Are there indexes on fk_lot_id and fk_unit_id ? If not, a DELETE from
lot will cause a seqscan of unit for affected units, and if any must be
deleted each will cause a seqscan of measurement for affected
measurements. That's going to get ugly fast.

--
Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2010-01-13 11:05:58 Re: Collate order on Mac OS X, text with diacritics in UTF-8
Previous Message Ralf Schuchardt 2010-01-13 10:25:53 What happens when you kill the postmaster?