iggy
iggy

Reputation: 1743

Postgres send output of COPY over the network

I would like to do the following:

psql -c "COPY (SELECT a.id, b.id FROM a JOIN b USING id) TO STDOUT;"

the problem is that it would never send anything until the join is fully computed. Is there a way to tell Postgres to output the join while its being computed without writing it into a some temporary storage?

Upvotes: 1

Views: 452

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 324541

Use psql's \copy.

\COPY (SELECT a.id, b.id FROM a JOIN b USING id) TO stdout;

You can replace stdout with '/path/to/file' if desired.

An inner join can be incrementally computed, so there should be no issues there presuming the tables aren't views over more complex queries. Show the output of explain select ... if you still don't get incremental output.

Upvotes: 1

Related Questions