insert into new_task(id, type, arguments, next_run, current_interval, status, policy, retries_left, priority) select id, type, arguments, next_run, current_interval, status, policy, retries_left, priority from task where ( policy='recurring' and (type = 'load-nixguix' or type like 'list-%' or type like 'index-%') ) or ( policy = 'oneshot' and next_run > now() - interval '2 months' ); INSERT 0 2929609 Time: 742707.838 ms (12:22.708) insert into new_task_run select id, task, backend_id, scheduled, started, ended, metadata, status from task_run where task in ( select distinct id from new_task ); INSERT 0 613863 Time: 242376.477 ms (04:02.376) select last_value from task_run_id_seq; last_value ------------ 1424372613 (1 row) Time: 0.206 ms alter table task rename to archive_task; ^CCancel request sent psql:33.sql:64: ERROR: canceling statement due to user request Time: 3397101.882 ms (56:37.102)