X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 0B9259DD4F3 for ; Wed, 7 Dec 2005 11:12:03 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12621-03 for ; Wed, 7 Dec 2005 11:12:01 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 0978B9DCD5F for ; Wed, 7 Dec 2005 11:11:54 -0400 (AST) 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 jB7FBuFp029271; Wed, 7 Dec 2005 10:11:56 -0500 (EST) To: Alexander Stanier cc: pgsql-sql@postgresql.org Subject: Re: How to increase row deletion efficiency? In-reply-to: <4396F360.6080000@egsgroup.com> References: <4396F360.6080000@egsgroup.com> Comments: In-reply-to Alexander Stanier message dated "Wed, 07 Dec 2005 14:36:16 +0000" Date: Wed, 07 Dec 2005 10:11:56 -0500 Message-ID: <29270.1133968316@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[AWL=0.001] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200512/58 X-Sequence-Number: 23600 Alexander Stanier writes: > I am currently trying to separate two environments contained in one > database. Essentially I need to break that one database down into two > with a portion of the data going to each new database. I am intending to > achieve this by duplicating the database and then stripping out the data > that is not required in each database. I have started by trying to > delete data from a set of 28 related tables, however the performance > appears to be terrible. I am deleting from a table called document which > cascades down to 27 tables underneath it linked by various cascading > foreign key constraints. Some of these subsidiary tables have as many as > a couple of million records. Do you have indexes on the referencing columns? PG enforces an index on the referenced column, but not on the other end, and DELETE is where it will hurt if you haven't got one. regards, tom lane