Re: Deleting millions of rows

Поиск
Список
Период
Сортировка
От Andrew Lazarus
Тема Re: Deleting millions of rows
Дата
Msg-id 1147694822.20090203140443@pillette.com
обсуждение исходный текст
Ответ на Re: Deleting millions of rows  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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
Вложения

В списке pgsql-performance по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Deleting millions of rows
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Deleting millions of rows