Single Row Mode in psql

From: Christopher Manning <c(at)christophermanning(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Single Row Mode in psql
Date: 2013-04-17 20:44:20
Message-ID: CAEYkp90OoiMGnDqsWf=w2rWFz07so6hrbzr3U1aFH4EkiL=AEg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm using psql to extract data from a redshift (based on postgres)
instance, but psql/libpq collects the result in memory before writing it to
a file and causes out of memory problems for large results. Using COPY TO
STDOUT or FETCH_COUNT isn't an option since redshift doesn't support those.

[Single Row Mode is available in postgres 9.2](
http://www.postgresql.org/docs/9.2/static/libpq-single-row-mode.html) but
[it doesn't look like](
http://www.postgresql.org/docs/9.2/static/app-psql.html) you can tell psql
to use it when writing to a file (using --output).

Is it currently possible to have psql --output to a file using single row
mode?

Thank you,
Christopher

P.S. The ruby-pg gem supports single row mode:
https://bitbucket.org/ged/ruby-pg/src/de1cdb0f7ba625ad7cec02bb871ae8fdf7de68c8/ext/pg_connection.c?at=default#cl-1514but
it has the overhead of being a ruby script instead of psql supporting
it.

Browse pgsql-general by date

  From Date Subject
Next Message Mike Roest 2013-04-17 20:45:52 Re: Fetching Server configured port from C Module
Previous Message François Beausoleil 2013-04-17 20:19:46 Re: Most efficient way to insert without duplicates