Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f4MEN4A80848 for ; Tue, 22 May 2001 10:23:04 -0400 (EDT) (envelope-from pgsql-interfaces-owner@postgresql.org) Received: from keittlab.bio.sunysb.edu (keittlab.bio.sunysb.edu [129.49.19.70]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4LF5oA60456 for ; Mon, 21 May 2001 11:05:50 -0400 (EDT) (envelope-from Timothy.Keitt@StonyBrook.Edu) Received: from keittlab-6.keittlab.bio.sunysb.edu ([192.168.1.6] helo=StonyBrook.Edu ident=tkeitt) by keittlab.bio.sunysb.edu with esmtp (Exim 3.12 #1 (Debian)) id 151rFd-0000XI-00; Mon, 21 May 2001 11:05:41 -0400 Message-ID: <3B092EC5.9060906@StonyBrook.Edu> Date: Mon, 21 May 2001 11:05:41 -0400 From: "Timothy H. Keitt" Organization: State University of New York at Stony Brook User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.19-smp i686; en-US; rv:0.9) Gecko/20010505 X-Accept-Language: en MIME-Version: 1.0 To: alexey@price.ru CC: pgsql-interfaces@postgresql.org Subject: Re: Subject: unbuffered results from libpq? References: <01051819460400.12019@workshop.price.ru> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200105/91 X-Sequence-Number: 1618 I realized after this post that one solution is to use a cursor. You can then fetch in small chuncks and write to a local buffer. The problem for a general interface applicaiton such as mine is nested transactions --- cursors can only be used within transactions which will fail if the the user has independently initiated a transaction (unless this has been fixed). Tim Alexey Nalbat wrote: > Hello. > > I have exactly the same question. Could anybody answer it? > > My impression is that it can't be maid. Even use of functions PQsetnonblocking, > PQsendQuery, PQgetResult, PQconsumeInput,.. doesn't help. Is it so? > > Thanks. > > >>My impression is that libpq buffers all results of a query. Is there a >>way to get a "result stream" from the backend instead of having libpq >>read everything into a local buffer first? Currently, my application, >>after a query, simply copies the entire buffer from the libpq side into >>storage on the application side. This seems expensive for large >>queries. I'd rather read results directly into storage on the >>application side, i.e., "while input get next value from backend". (I >>know about libpqeasy, but this only iterates over the libpq buffer.) >> > -- Timothy H. Keitt Department of Ecology and Evolution State University of New York at Stony Brook Stony Brook, New York 11794 USA Phone: 631-632-1101, FAX: 631-632-7626 http://life.bio.sunysb.edu/ee/keitt/