How to efficiently copy millions of rows from one table to another in Postgresql?
Dump the table in csv format

COPY table TO '/tmp/table.csv' DELIMITER ',';


use the COPY command which is far more efficient for large amounts of data.

COPY table FROM '/tmp/table.csv' DELIMITER ',';


Check postgres docs at http://www.postgresql.org/docs/current/static/sql-copy.html for more info