Advance primary key after mass insert
SELECT setval(pg_get_serial_sequence('tbl', 'tbl_id'), max(tbl_id)) FROM tbl; 


Table name and column name are two separate parameters to the pg_get_serial_sequence() function.
And you don't need a subselect.
Details:


How to reset postgres' primary key sequence when it falls out of sync?
Reset the sequence of a serial PK with dynamic SQL