Re: [GENERAL] efficiently migrating 'old' data from one table to another

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [GENERAL] efficiently migrating 'old' data from one table to another
Дата
Msg-id CAKFQuwbk4KgA4y+uNRJnB=LZqgrT1uKFOF0WMNnZMa3B53S4Qg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [GENERAL] efficiently migrating 'old' data from one table toanother  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
On Thu, Jan 12, 2017 at 2:45 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:

> so our migration is then based on that `is_migrate` column:
>
>       BEGIN;
>       UPDATE table_a__live SET is_migrate = TRUE WHERE record_timestamp < transaction_timestamp() AT TIME ZONE 'UTC' - INTERVAL '1 month';
>       INSERT INTO table_a__archive (column_1, column_2, record_timestamp) SELECT column_1, column_2, record_timestamp FROM table_a__live WHERE is_migrate IS TRUE;
>       DELETE FROM table_a__live WHERE is_migrate IS TRUE;
>       COMMIT;
>
> The inserts & deletes are blazing fast, but the UPDATE is a bit slow from postgres re-writing all the rows.

Maybe I am missing something, but why do the UPDATE?

​Not to mention doubling the amount of I/O vacuum is going to chew up.

​David J.

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: [GENERAL] efficiently migrating 'old' data from one table toanother
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: [GENERAL] efficiently migrating 'old' data from one table to another