Re: Deleting millions of rows - Mailing list pgsql-performance

From Andrew Lazarus
Subject Re: Deleting millions of rows
Date
Msg-id 1147694822.20090203140443@pillette.com
Whole thread Raw
In response to Re: Deleting millions of rows  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@pillette.com
Attachment

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Deleting millions of rows
Next
From: Robert Haas
Date:
Subject: Re: Deleting millions of rows