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 9982D9DCBB0 for ; Wed, 21 Dec 2005 05:39:19 -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 86789-02 for ; Wed, 21 Dec 2005 05:39:20 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 497599DCBBB for ; Wed, 21 Dec 2005 05:39:16 -0400 (AST) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id F3EEF4130C3; Wed, 21 Dec 2005 09:38:22 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 17FE515EA4; Wed, 21 Dec 2005 09:38:28 +0000 (GMT) Message-ID: <43A92293.6000309@archonet.com> Date: Wed, 21 Dec 2005 09:38:27 +0000 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051025) MIME-Version: 1.0 To: Smita Mahadik Cc: pgsql-sql@postgresql.org Subject: Re: Commiting after certain no of rows have been deleted References: <006d01c60278$2943d440$86ea52c7@smita> In-Reply-To: <006d01c60278$2943d440$86ea52c7@smita> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.01 required=5 tests=[AWL=0.010] X-Spam-Score: 0.01 X-Spam-Level: X-Archive-Number: 200512/191 X-Sequence-Number: 23733 Smita Mahadik wrote: > Hi, > > In my application I m deleteing large no of rows from table based on > certain condition. This takes lot of time and if sometimes my > application fails it starts all over again...since the coomit is done > at the end of transactions. Is there a way i can do commit when > certain no of rows have been deleted? For eg if i need to delete 2 > million rows i should be able to commit after say 10,000 rows. No - the whole point of the transaction is it all works or none of it does. But, if you have a suitable ID/Name/timestamp/other varying column you can break it into smaller chunks: DELETE FROM contacts WHERE surname LIKE 'A%'; DELETE FROM contacts WHERE surname LIKE 'B%'; ...etc... don't forget a final "full" delete to catch anything you miss DELETE FROM contacts; Ideally you'll have something with an index on it. -- Richard Huxton Archonet Ltd