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 38A3ED841D for ; Tue, 6 Sep 2005 12:43:24 -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 01214-02 for ; Tue, 6 Sep 2005 15:43:18 +0000 (GMT) Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) by svr1.postgresql.org (Postfix) with ESMTP id 241E8D8138 for ; Tue, 6 Sep 2005 12:43:16 -0300 (ADT) Received: (qmail 20095 invoked by uid 1004); 6 Sep 2005 15:43:15 -0000 Received: from 10.224.189.77 by newman (envelope-from , uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. Clear:RC:1(10.224.189.77):. Processed in 0.013821 secs); 06 Sep 2005 15:43:15 -0000 Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) (envelope-sender ) by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 6 Sep 2005 15:43:15 -0000 Date: Tue, 6 Sep 2005 16:43:15 +0100 From: Matthew Sackman To: pgsql-performance@postgresql.org Subject: Re: Poor performance of delete by primary key Message-ID: <20050906154315.GL382@pongo.lshift.net> Mail-Followup-To: pgsql-performance@postgresql.org References: <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> <18162.1126020720@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18162.1126020720@sss.pgh.pa.us> User-Agent: Mutt/1.5.10i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.269 required=5 tests=[AWL=-0.105, DNS_FROM_RFC_ABUSE=0.374] X-Spam-Level: X-Archive-Number: 200509/94 X-Sequence-Number: 14402 On Tue, Sep 06, 2005 at 11:32:00AM -0400, Tom Lane wrote: > "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. Wouldn't setting the FK as deferrable and initially deferred help here too as then the FK wouldn't be checked until the transaction ended? Matthew