"so bottle neck have to be some where between client and server" that's what I need to know ! where is the bug to made this performance
Did you executed it from psql? Tried with \copy also? (sorry if you answered it already and I missed).
"Can you try again but with EXPLAIN *ANALYZE* (not only EXPLAIN)?" it's not a matter of plan problem I think, it's related to sending data from server to client, perhaps in allocating buffers for data or problem in libpq I don't know ... because why it's super fast exporting same select to file using copy command. again I am using the same pc of the postgresql server
I'd like to see the EXPLAIN ANALYZE to see the real query execution time only (discarding even the write of output of COPY command), and also see if the query can be improved with an index or so, I haven't say it is a plan problem, as nothing suggested that so far.
Also, what OS are you on? Are you connecting through TCP or domain socket?
Best regards,
--
Matheus de Oliveira Analista de Banco de Dados Dextra Sistemas - MPS.Br nível F! www.dextra.com.br/postgres