X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 2BED09FB249 for ; Tue, 19 Sep 2006 11:16:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 83659-07-3 for ; Tue, 19 Sep 2006 14:16:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) by postgresql.org (Postfix) with ESMTP id 74EB19FB289 for ; Tue, 19 Sep 2006 11:15:31 -0300 (ADT) Received: from einstein.muc.ecircle.de (einstein.muc.ecircle.de [192.168.1.7]) by mail.ecircle.de (READY) with ESMTP id 71ADB55C006; Tue, 19 Sep 2006 16:15:29 +0200 (CEST) Received: from [192.168.1.91] ([192.168.1.91]) by einstein.muc.ecircle.de with Microsoft SMTPSVC(6.0.3790.1830); Tue, 19 Sep 2006 16:16:11 +0200 Subject: Re: Optimizing DELETE From: Csaba Nagy To: Ivan Voras Cc: postgres performance list In-Reply-To: <450FEF1A.4070106@fer.hr> References: <450FEF1A.4070106@fer.hr> Content-Type: text/plain Message-Id: <1158675328.25023.216.camel@coppola.muc.ecircle.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 19 Sep 2006 16:15:29 +0200 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Sep 2006 14:16:11.0238 (UTC) FILETIME=[285ED860:01C6DBF6] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200609/253 X-Sequence-Number: 20939 > 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.