Re: Optimizing DELETE

From: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
To: Ivan Voras <ivoras(at)fer(dot)hr>
Cc: postgres performance list <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Optimizing DELETE
Date: 2006-09-19 14:15:29
Message-ID: 1158675328.25023.216.camel@coppola.muc.ecircle.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> I've just fired off a "DELETE FROM table" command (i.e. unfiltered
> DELETE) on a trivially small table but with many foreign key references
> (on similar-sized tables), and I'm waiting for it to finish. It's been
> 10 minutes now, which seems very excessive for a table of 9000 rows on a
> 3 GHz desktop machine.

If you have missing indexes on the child tables foreign keys, that might
be a cause of slow delete. The cascading delete must look up the to be
deleted rows in all child tables, which will do sequential scans if you
don't have proper indexes.

Try to do an explain analyze for deleting one row, that should also show
you the time spent in triggers, which might clue you in what's taking so
long.

Cheers,
Csaba.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mark Lewis 2006-09-19 14:17:25 Re: Optimizing DELETE
Previous Message Bucky Jordan 2006-09-19 13:58:20 Re: Large tables (was: RAID 0 not as fast as expected)