pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Csaba Nagy <nagy@ecircle-ag.com>
To: Ivan Voras <ivoras@fer.hr>
Cc: postgres performance list <pgsql-performance@postgresql.org>
Subject: Re: Optimizing DELETE
Date: Tue, 19 Sep 2006 16:15:29 +0200
Message-ID: <1158675328.25023.216.camel@coppola.muc.ecircle.de> (raw)
In-Reply-To: <450FEF1A.4070106@fer.hr>
References: <450FEF1A.4070106@fer.hr>

> 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.





view thread (5+ messages)  latest in thread

Message-ID: <1158675328.25023.216.camel@coppola.muc.ecircle.de>
Permalink:  ../1158675328.25023.216.camel@coppola.muc.ecircle.de/
Also on:    postgresql.org/message-id/1158675328.25023.216.camel@coppola.muc.ecircle.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: nagy@ecircle-ag.com, ivoras@fer.hr
  Subject: Re: Optimizing DELETE
  In-Reply-To: <1158675328.25023.216.camel@coppola.muc.ecircle.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox