X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0665952816 for ; Thu, 7 Jul 2005 08:16:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76379-06 for ; Thu, 7 Jul 2005 11:16:40 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) by svr1.postgresql.org (Postfix) with ESMTP id 683F8529BF for ; Thu, 7 Jul 2005 08:16:36 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 69so178096wri for ; Thu, 07 Jul 2005 04:16:40 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=MqFLFn6b6HYDLVpxEECKfPkuwfc0FNn0Rp76D87fR/A4nuKAxWrNAVB8Uekw/UBSsS8hkvvwxaCCkG4s2cr1j5JcvfV6FBSukR76cTcliyjOO1pn26YgtzsLOjs89k1+dhgThsUiYDtHZHM5NXE3QrTKa1ttDUJlPEe+KE3vhEM= Received: by 10.54.29.10 with SMTP id c10mr615683wrc; Thu, 07 Jul 2005 04:16:39 -0700 (PDT) Received: from ?10.80.1.45? ([194.248.208.82]) by mx.gmail.com with ESMTP id d61sm1040970wra.2005.07.07.04.16.39; Thu, 07 Jul 2005 04:16:39 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v728) Content-Transfer-Encoding: 7bit Message-Id: <6F239216-7936-4E62-B708-46DC9171649C@gmail.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: pgsql-performance@postgresql.org From: Bendik Rognlien Johansen Subject: How to speed up delete Date: Thu, 7 Jul 2005 13:16:30 +0200 X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.141 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200507/62 X-Sequence-Number: 13303 Hello, I was wondering if there is any way to speed up deletes on this table (see details below)? I am running few of these deletes (could become many more) inside a transaction and each one takes allmost a second to complete. Is it because of the foreign key constraint, or is it something else? Thanks! Table "public.contacts" Column | Type | Modifiers -------------+------------------------ +---------------------------------------------------------- id | integer | not null default nextval ('public.contacts_id_seq'::text) record | integer | type | integer | value | character varying(128) | description | character varying(255) | priority | integer | itescotype | integer | original | integer | Indexes: "contacts_pkey" PRIMARY KEY, btree (id) "contacts_record_idx" btree (record) Foreign-key constraints: "contacts_original_fkey" FOREIGN KEY (original) REFERENCES contacts(id) dev=# select count(id) from contacts; count -------- 984834 (1 row) dev=# explain analyze DELETE FROM contacts WHERE id = 985458; QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------ Index Scan using contacts_pkey on contacts (cost=0.00..3.01 rows=1 width=6) (actual time=0.043..0.049 rows=1 loops=1) Index Cond: (id = 985458) Total runtime: 840.481 ms (3 rows)