From: | Andrew Lazarus <andrew(at)pillette(dot)com> |
---|---|
To: | "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Deleting millions of rows |
Date: | 2009-02-03 22:04:43 |
Message-ID: | 1147694822.20090203140443@pillette.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Hello All,
TL> If you're deleting very many but not all rows, people tend
TL> to drop the FK constraints and re-establish them afterwards.
I find
BEGIN;
CREATE TEMP TABLE remnant AS
SELECT * FROM bigtable WHERE (very_restrictive_condition);
TRUNCATE TABLE bigtable;
INSERT INTO bigtable SELECT * FROM remnant;
COMMIT;
ANALYSE bigtable;
works well because there is no possibility of my forgetting FKs.
--
Sincerely,
Andrew Lazarus mailto:andrew(at)pillette(dot)com
Attachment | Content-Type | Size |
---|---|---|
vCard.VCF | text/x-vcard | 378 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2009-02-04 00:08:59 | Re: Deleting millions of rows |
Previous Message | Tom Lane | 2009-02-03 21:17:29 | Re: Deleting millions of rows |