Why use COPY for the second table? I would suggest that doing:
INSERT INTO table2 (...)
SELECT ...
FROM table1;
will be faster than using COPY.
Edit
If you need to import different rows into different tables, but from the same source file, it is possible to insert everything into an intermediate table, and then insert rows from there into the target tables faster:
Import the .whole * text file into one staging table:
COPY staging_table FROM STDIN ...;
After this step, the entire input file is in staging_table
Then copy the rows from the staging table to the individual target tables, selecting only those that correspond to the corresponding table:
INSERT INTO table_1 (...)
SELECT ...
FROM staging_table
WHERE (conditions for table_1);
INSERT INTO table_2 (...)
SELECT ...
FROM staging_table
WHERE (conditions for table_2);
This, of course, is only possible if you have enough space in your database to support the staging table.
source share