Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 3CAB39FB4EC for ; Thu, 22 Feb 2007 07:12:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 57439-08 for ; Thu, 22 Feb 2007 07:12:29 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id C3CE09FB4DD for ; Thu, 22 Feb 2007 07:12:32 -0400 (AST) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 82E9374837; Thu, 22 Feb 2007 11:12:12 +0000 (GMT) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 8818F27415D; Thu, 22 Feb 2007 11:12:11 +0000 (GMT) Message-ID: <45DD7A8B.3040001@archonet.com> Date: Thu, 22 Feb 2007 11:12:11 +0000 From: Richard Huxton User-Agent: IceDove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: Konstantinos Krikellas Cc: pgsql-performance Subject: Re: Disable result buffering to frontend clients References: <1172142170.4718.13.camel@kkrik-desktop> In-Reply-To: <1172142170.4718.13.camel@kkrik-desktop> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.196 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200702/229 X-Sequence-Number: 23283 Konstantinos Krikellas wrote: > Hi, > > I am trying to execute some queries in PostgreSQL that produce a large > number of results and I do not want to display the output (redirect it > to /dev/null). I have tried the psql client with \o /dev/null option, > JDBC and libpq functions, but all of them have to buffer totally the > result before redirecting it. Is there any way to disable result > buffering, either on the client or on the server side? Well, you could use a cursor, but that could change the plan (I believe it favours plans that return the first result quickly). You could have a function that used FOR-IN-EXECUTE to run a query for you then just loop through the results, doing nothing. That would keep everything server-side. If you really want to duplicate all the query costs except client-side buffering, the simplest might be to just hack the libpq source to discard any query results rather than buffering them - shouldn't be too difficult. -- Richard Huxton Archonet Ltd