Why does it take so long for Postgres to return a sequence number?
I have studied your question hard, but can't make sense of the procedure you describe. (You might work on the description some more.)

Why would you generate sequence numbers by hand, when you can just have Postgres generate them automatically? Per documentation:


  If a list of columns is specified, COPY will only copy the data in the
  specified columns to or from the file. If there are any columns in the
  table that are not in the column list, COPY FROM will insert the
  default values for those columns.


Bold emphasis mine. The default value for a serial column is the next id from its sequence.

Are you sure you are not doing a lot of redundant work in a very expensive fashion?