Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 94F8B63402F for ; Fri, 2 Apr 2010 19:20:39 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 08381-05 for ; Fri, 2 Apr 2010 22:20:23 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from itmxipcp01.med.harvard.edu (gate3.med.harvard.edu [134.174.150.162]) by mail.postgresql.org (Postfix) with ESMTP id E5C5563460E for ; Fri, 2 Apr 2010 19:20:28 -0300 (ADT) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al0EALQKtkuGrg4qkWdsb2JhbACDEZdpUhUBAQEBFBERIqN0hzqIW4Ergm1tBA X-IronPort-AV: E=Sophos;i="4.51,355,1267419600"; d="scan'208,217";a="43462352" Received: from itwmxhtp02.med.harvard.edu ([134.174.14.42]) by itmxipcp01.med.harvard.edu with ESMTP/TLS/AES128-SHA; 02 Apr 2010 18:20:27 -0400 Received: from john-beavers-macbook-pro-2.local (134.174.14.29) by ITWMXHTP02.MED.HARVARD.EDU (134.174.14.120) with Microsoft SMTP Server (TLS) id 8.1.359.3; Fri, 2 Apr 2010 18:20:27 -0400 Message-ID: <4BB66D7A.1090605@hms.harvard.edu> Date: Fri, 2 Apr 2010 18:19:38 -0400 From: John Beaver User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) MIME-Version: 1.0 To: Pierre C CC: "pgsql-performance@postgresql.org" Subject: Re: *** PROBABLY SPAM *** Does the psql executable support a "fetch many" approach when dumping large queries to stdout? References: <62307826D0C1F74BAFE47B6747FA8C2C5407AED155@ITCCRMAIL02.MED.HARVARD.EDU> In-Reply-To: Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.498 tagged_above=-10 required=5 tests=AWL=-0.961, BAYES_50=0.001, HTML_MESSAGE=0.001, MIME_HTML_ONLY=1.457 X-Spam-Level: X-Archive-Number: 201004/24 X-Sequence-Number: 38274 That makes sense. I'll just use a COPY statement instead like Hannu suggests.

Pierre C wrote:
Does the psql executable have any ability to do a "fetch many", using a  
server-side named cursor, when returning results? It seems like it tries  
to retrieve the query entirely to local memory before printing to  
standard out.
    

I think it grabs the whole result set to calculate the display column  
widths. I think there is an option to tweak this but don't remember which,  
have a look at the psql commands (\?), formatting section.
  

-- 
John E. Beaver
Bioinformatics Developer
Harvard Medical School