From: Kris Jurka <books@ejurka.com>
To: Craig Ringer <ringerc@ringerc.id.au>
Cc: Radim Kolar <hsn@filez.com>
Cc: Dave Cramer <pg@fastcrypt.com>
Cc: PostgreSQL JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: not fetching all query results
Date: Thu, 19 Jul 2012 22:44:02 -0700
Message-ID: <5008F022.40503@ejurka.com> (raw)
In-Reply-To: <5008E9AC.8030507@ringerc.id.au>
References: <50044D96.3050902@filez.com>
<5004D8F2.509@ringerc.id.au>
<50055065.6080308@filez.com>
<CADK3HH+UboShbu12+V3N21wtXoEW4vYPHydWVcn47n01i2jjug@mail.gmail.com>
<500585D1.1000801@filez.com>
<CADK3HHLx74z3c=YNvRYBsxErfVyifchzEcuwXgpgN4C_YAhtQQ@mail.gmail.com>
<5005AB7C.5010508@filez.com>
<CADK3HH+03Z3jik+G5XTpT9C0H3JzOgomYHL1fTNVi-ZJFdtRwQ@mail.gmail.com>
<CADK3HH+HEot-uX0Vd23dN0nQW8Nrp2+E6gTFVN9TvLWHW7-cLw@mail.gmail.com>
<5005C1AC.1030106@filez.com>
<CADK3HHLOhLMBcMymZQAkWKubfvQKpkcZpaePH9yQJq-V0Ksucg@mail.gmail.com>
<5005D257.9000100@filez.com>
<5008E9AC.8030507@ringerc.id.au>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: books@ejurka.com, ringerc@ringerc.id.au, hsn@filez.com, pg@fastcrypt.com
Subject: Re: not fetching all query results
In-Reply-To: <5008F022.40503@ejurka.com>
References: <50044D96.3050902@filez.com> <5004D8F2.509@ringerc.id.au> <50055065.6080308@filez.com> <CADK3HH+UboShbu12+V3N21wtXoEW4vYPHydWVcn47n01i2jjug@mail.gmail.com> <500585D1.1000801@filez.com> <CADK3HHLx74z3c=YNvRYBsxErfVyifchzEcuwXgpgN4C_YAhtQQ@mail.gmail.com> <5005AB7C.5010508@filez.com> <CADK3HH+03Z3jik+G5XTpT9C0H3JzOgomYHL1fTNVi-ZJFdtRwQ@mail.gmail.com> <CADK3HH+HEot-uX0Vd23dN0nQW8Nrp2+E6gTFVN9TvLWHW7-cLw@mail.gmail.com> <5005C1AC.1030106@filez.com> <CADK3HHLOhLMBcMymZQAkWKubfvQKpkcZpaePH9yQJq-V0Ksucg@mail.gmail.com> <5005D257.9000100@filez.com> <5008E9AC.8030507@ringerc.id.au> <5008F022.40503@ejurka.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox