From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Smita Mahadik <smita(dot)mahadik(at)fedex(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Commiting after certain no of rows have been deleted |
Date: | 2005-12-21 09:38:27 |
Message-ID: | 43A92293.6000309@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2005-12-21 10:04:50 | Re: Help on a complex query (avg data for day of the week) |
Previous Message | Richard Huxton | 2005-12-21 09:34:32 | Re: Help me do a LOOP |