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 7A2339FB256 for ; Tue, 19 Sep 2006 10:48:19 -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 55804-01-4 for ; Tue, 19 Sep 2006 13:47:40 +0000 (UTC) X-Greylist: delayed 00:21:02.087111 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 142319FB305 for ; Tue, 19 Sep 2006 10:43:47 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from lara.cc.fer.hr (lara.cc.fer.hr [161.53.72.113]) by svr4.postgresql.org (Postfix) with ESMTP id 2E3E95AF889 for ; Tue, 19 Sep 2006 13:22:46 +0000 (GMT) Received: from [IPv6:::1] (localhost.cc.fer.hr [IPv6:::1]) by lara.cc.fer.hr (8.13.8/8.13.4) with ESMTP id k8JDMYOm012767 for ; Tue, 19 Sep 2006 15:22:38 +0200 (CEST) (envelope-from ivoras@fer.hr) Message-ID: <450FEF1A.4070106@fer.hr> Date: Tue, 19 Sep 2006 15:22:34 +0200 From: Ivan Voras User-Agent: Thunderbird 1.5.0.4 (X11/20060625) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Optimizing DELETE Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200609/251 X-Sequence-Number: 20937 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. '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)