X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BDAD9D7D71 for ; Tue, 6 Sep 2005 12:32:06 -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 95763-05 for ; Tue, 6 Sep 2005 15:32:04 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 40867D7CFE for ; Tue, 6 Sep 2005 12:32:03 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j86FW1Ws018163; Tue, 6 Sep 2005 11:32:01 -0400 (EDT) To: "Brian Choate" Cc: pgsql-performance@postgresql.org Subject: Re: Poor performance of delete by primary key In-reply-to: <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> References: <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> Comments: In-reply-to "Brian Choate" message dated "Tue, 06 Sep 2005 08:04:22 -0700" Date: Tue, 06 Sep 2005 11:32:00 -0400 Message-ID: <18162.1126020720@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/93 X-Sequence-Number: 14401 "Brian Choate" writes: > We are seeing a very strange behavior from postgres. For one of our very = > common tasks we have to delete records from a table of around 500,000 = > rows. The delete is by id which is the primary key. It seems to be = > consistently taking around 10 minutes to preform. This is totally out of = > line with the rest of the performance of the database. I'll bet this table has foreign-key references from elsewhere, and the referencing columns are either not indexed, or not of the same datatype as the master column. Unfortunately there's no very simple way to determine which FK is the problem. (In 8.1 it'll be possible to do that with EXPLAIN ANALYZE, but in existing releases EXPLAIN doesn't break out the time spent in each trigger ...) You have to just eyeball the schema :-(. regards, tom lane