X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 72AAB9FB2A5 for ; Tue, 19 Sep 2006 11:17:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 70598-03-2 for ; Tue, 19 Sep 2006 11:17:23 -0300 (ADT) X-Greylist: delayed 00:23:54.303272 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id BE8E89FB2B1 for ; Tue, 19 Sep 2006 11:17:08 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from gatekeeper.look.ca (gamma1.look.ca [207.136.80.8]) by svr4.postgresql.org (Postfix) with ESMTP id 7148F5AF8C3 for ; Tue, 19 Sep 2006 13:53:12 +0000 (GMT) Received: from 209-161-213-206.dsl.look.ca ([209.161.213.206]) by gatekeeper.look.ca with esmtp (Exim 4.20) id 1GPg27-0003t9-UO; Tue, 19 Sep 2006 13:53:07 +0000 From: Rod Taylor To: Ivan Voras Cc: pgsql-performance@postgresql.org In-Reply-To: <450FEF1A.4070106@fer.hr> References: <450FEF1A.4070106@fer.hr> Date: Tue, 19 Sep 2006 09:53:07 -0400 Message-Id: <1158673987.71040.24.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 FreeBSD GNOME Team Port X-SA-Exim-Mail-From: rbt@rbt.ca Subject: Re: Optimizing DELETE Content-Type: text/plain Content-Transfer-Encoding: 7bit X-SA-Exim-Version: 3.1 (built Tue Feb 24 05:09:27 GMT 2004) X-SA-Exim-Scanned: Yes X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200609/254 X-Sequence-Number: 20940 On Tue, 2006-09-19 at 15:22 +0200, Ivan Voras wrote: > 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. I would guess that a few of those referenced tables are missing indexes on the referenced column. > 'top' says it's all spent in USER time, and there's a ~~500KB/s write > rate going on. Just before this DELETE, I've deleted data from a larger > table (50000 rows) using the same method and it finished in couple of > seconds - maybe it's a PostgreSQL bug? > > My question is: assuming it's not a bug, how to optimize DELETEs? > Increasing work_mem maybe? > > (I'm using PostgreSQL 8.1.4 on FreeBSD 6- amd64) > > (I know about TRUNCATE; I need those foreign key references to cascade) > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend >