Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 0870C9FB6E6 for ; Tue, 3 Apr 2007 03:39:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 35973-04 for ; Tue, 3 Apr 2007 03:39:36 -0300 (ADT) X-Greylist: delayed 00:28:47.050525 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id A0E599FB88E for ; Tue, 3 Apr 2007 03:39:37 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from outK.internet-mail-service.net (outK.internet-mail-service.net [216.240.47.234]) by svr4.postgresql.org (Postfix) with ESMTP id ADBE35AF02C for ; Tue, 3 Apr 2007 06:10:49 +0000 (GMT) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.32) with ESMTP; Mon, 02 Apr 2007 22:41:00 -0700 Received: from [192.168.1.109] (adsl-71-135-160-185.dsl.pltn13.pacbell.net [71.135.160.185]) by idiom.com (Postfix) with ESMTP id DEDDE125ADC for ; Mon, 2 Apr 2007 23:10:41 -0700 (PDT) Message-ID: <4611EFE1.5010400@obviously.com> Date: Mon, 02 Apr 2007 23:10:41 -0700 From: Bryce Nesbitt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20061107 SUSE/1.1.1-0.1 SeaMonkey/1.1.1 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Very slow DELETE on 4000 rows of 55000 row table Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/15 X-Sequence-Number: 28015 I've got a DELETE FROM that seems to run forever, pegging the CPU at 100%. I can't figure out why it's slow. Any clues? stage=# EXPLAIN DELETE FROM EG_INVOICE WHERE PERIOD_ID = 1017506; Index Scan using ix22f7bc70c7de2059 on eg_invoice (cost=0.00..105.39 rows=3955 width=6) Index Cond: (period_id = 1017506) stage=# select count(*) FROM EG_INVOICE; 55376 stage=# select count(*) FROM EG_INVOICE where PERIOD_ID = 1017506;; 4603 stage=# \d EG_INVOICE; Table "public.eg_invoice" Column | Type | Modifiers ----------------+------------------------+----------- invoice_id | integer | not null cso_id | integer | not null period_id | integer | not null invoice_number | character varying(192) | invoice_date | date | plan_name | character varying(128) | invoice_style | integer | not null account_id | integer | Indexes: "eg_invoice_pkey" PRIMARY KEY, btree (invoice_id) "invoice_number_idx" btree (invoice_number) "ix22f7bc70c7de2059" btree (period_id) Foreign-key constraints: "fk22f7bc70c7de2059" FOREIGN KEY (period_id) REFERENCES eg_billing_period(period_id) "invoice_to_account" FOREIGN KEY (account_id) REFERENCES eg_account(account_id) "invoice_to_cso" FOREIGN KEY (cso_id) REFERENCES eg_cso(cso_id) stage=# vacuum analyze verbose EG_INVOICE; ... INFO: "eg_invoice": scanned 584 of 584 pages, containing 55376 live rows and 0 dead rows; 3000 rows in sample, 55376 estimated total rows PostgreSQL 8.1.8 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-51) -- ---- Visit http://www.obviously.com/