Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 7E3FE1C0B196 for ; Fri, 20 Jul 2012 02:44:34 -0300 (ADT) Received: from mail63.csoft.net ([205.205.214.4]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ss60r-0006lI-FJ for pgsql-jdbc@postgresql.org; Fri, 20 Jul 2012 05:44:33 +0000 Received: from mail63.csoft.net (localhost [127.0.0.1]) by mail63.csoft.net (Postfix) with ESMTP id 43BC328412; Fri, 20 Jul 2012 01:44:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=csoft.net; h=message-id :date:from:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; s=sel1; bh=l/M23Uob0xH4 e1I5eE63od2GG50=; b=wlzoE0PrI57gdzB+clU5asywnzqSyBAyin0ulo0vvmaE 57+nuagdjE1ZemAd6II1vuEu6XqYaU38GciQUp5TOXFU70kv3LmLDVUwnNVrfEXe YptMFXmf8iFgqXzTomDpK90V8ku6XWcj6+PLNo+MOW8FXlkGa/n5J65ypgfrRrI= Received: from [192.168.7.100] (cpe-72-134-104-19.socal.res.rr.com [72.134.104.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail63.csoft.net (Postfix) with ESMTPSA id 897F22840E; Fri, 20 Jul 2012 01:44:14 -0400 (EDT) Message-ID: <5008F022.40503@ejurka.com> Date: Thu, 19 Jul 2012 22:44:02 -0700 From: Kris Jurka User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Craig Ringer CC: Radim Kolar , Dave Cramer , PostgreSQL JDBC Subject: Re: not fetching all query results References: <50044D96.3050902@filez.com> <5004D8F2.509@ringerc.id.au> <50055065.6080308@filez.com> <500585D1.1000801@filez.com> <5005AB7C.5010508@filez.com> <5005C1AC.1030106@filez.com> <5005D257.9000100@filez.com> <5008E9AC.8030507@ringerc.id.au> In-Reply-To: <5008E9AC.8030507@ringerc.id.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/35 X-Sequence-Number: 23133 On 7/19/2012 10:16 PM, Craig Ringer wrote: > I haven't looked into how the fetch size code works to see whether it's > possible for it to operate in autocommit. > > given that and the subsequent code I don't understand why an explicit > transaction is required. I've only done a tiny bit with the JDBC code, > though, and only related to the authentication system and client > certificates. A transaction is required to keep the portal (protocol level cursor) open. In autocommit mode, each batch fetched runs in its own transaction. So after the first batch is fetched, the autocommit transaction ends and the cursor is destroyed. So the next batch fetch cannot work. For multiple fetches to work in autocommit mode, you need a WITH HOLD cursor. This has a performance impact and you cannot create a WITH HOLD portal at the protocol level. So making this work is decidedly non-trivial. You would need to rework the query processor to rewrite the SQL to be a CREATE CURSOR statement. A similar problem occurs when trying to make fetchsize work for scrollable resultsets. You can't create a scrollable portal at the protocol level and you cannot move any direction other than forwards at the protocol level. So the JDBC team has been sort of waiting for the frontend/backend protocol to support these features before supporting them in the drive. The one thing that could be fixed is making refcursors respect fetchsize with the same restrictions as the current normal query process. Kris Jurka