pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Smita Mahadik <smita.mahadik@fedex.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Commiting after certain no of rows have been deleted
Date: Wed, 21 Dec 2005 09:38:27 +0000
Message-ID: <43A92293.6000309@archonet.com> (raw)
In-Reply-To: <006d01c60278$2943d440$86ea52c7@smita>
References: <006d01c60278$2943d440$86ea52c7@smita>

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



view thread (2+ messages)

Message-ID: <43A92293.6000309@archonet.com>
Permalink:  ../43A92293.6000309@archonet.com/
Also on:    postgresql.org/message-id/43A92293.6000309@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, smita.mahadik@fedex.com
  Subject: Re: Commiting after certain no of rows have been deleted
  In-Reply-To: <43A92293.6000309@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox