From: Oliver Jowett <oliver@opencloud.com>
To: Andy Zeneski <jaz@ofbiz.org>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Result Set Cursor Patch
Date: Sat, 01 May 2004 13:51:40 +1200
Message-ID: <409302AC.6030807@opencloud.com> (raw)
In-Reply-To: <53AED150-9B0C-11D8-A094-000A95DA1A7C@ofbiz.org>
References: <AC8D227A-9AB7-11D8-A094-000A95DA1A7C@ofbiz.org>
<Pine.BSO.4.56.0404301035120.23452@leary.csoft.net>
<B3BDBEB6-9ABF-11D8-A094-000A95DA1A7C@ofbiz.org>
<Pine.BSO.4.56.0404301115170.23452@leary.csoft.net>
<CDF53B82-9AC2-11D8-A094-000A95DA1A7C@ofbiz.org>
<Pine.BSO.4.56.0404301128280.15995@leary.csoft.net>
<AC9E43EA-9AC7-11D8-A094-000A95DA1A7C@ofbiz.org>
<164902F2-9AE8-11D8-A094-000A95DA1A7C@ofbiz.org>
<4092DAE1.5020500@opencloud.com>
<53AED150-9B0C-11D8-A094-000A95DA1A7C@ofbiz.org>
Andy Zeneski wrote:
>> fetchAbsolute() and things that end up calling it doesn't seem to
>> respect the fetchsize, i.e. you always end up with a single-row
>> resultset in memory. How about executing "MOVE ABSOLUTE n; FETCH
>> FORWARD fetchsize" instead of just "FETCH ABSOLUTE n"?
>>
>
> Now that I have code in place for MOVE, this will be simple to implement.
I realized there's an off-by-one error in my example above (I think!) --
as the FETCH will start with the next row after 'n'. Something to watch for.
>> How does the performance of iterating backwards through a resultset
>> compare with the non-cursor case or the forward iteration case? It
>> seems like with the patch it will end up doing a FETCH ABSOLUTE of a
>> single row on each iteration. Really fetchAbsolute needs to do either
>> a "MOVE ABSOLUTE n; FETCH FORWARD fetchsize" or "MOVE ABSOLUTE n;
>> FETCH BACKWARD fetchsize" depending on the resultset's preferred fetch
>> direction (see setFetchDirection)
>>
>
> Okay, now I must ask for some help. In the case that the direction is
> reverse, does that mean that the pointer should position itself at the
> last record at the beginning? What about unknown, should that default to
> forward?
What I mean is that if you've set the fetch direction to backwards, the
driver should probably fetch a block *ending* at the row that it wants
to fetch but doesn't currently have in memory, rather than a block
starting at that row. FETCH BACKWARD is one way of doing this (you'll
need to reverse the order of rows returned though).
i.e. with fetchsize 5 and FETCH_FORWARD we fetch this block:
10 <= desired row
11
12
13
14
With FETCH_REVERSE we should instead fetch this block:
6
7
8
9
10 <= desired row
After thinking about this a bit it's probably simpler to use a FETCH
FORWARD to get a block of 'fetchsize' rows starting at max(1, row -
fetchsize + 1), i.e. fetch forward from row 6 in the above example.
> Also, when in reverse mode should next() still go forward, or should
> everything be reversed? Meaning, next() would go backwards and
> previous() would go forwards?
setFetchDirection() lets the application provide a hint about the likely
access pattern; the actual meaning of all the resultset positioning
operations are unchanged. it's just there to help the driver load rows
efficiently.
The javadoc says:
> public static final int FETCH_REVERSE
>
> The constant indicating that the rows in a result set will be processed
> in a reverse direction; last-to-first. This constant is used by the
> method setFetchDirection as a hint to the driver, which the driver may
> ignore.
-O
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: oliver@opencloud.com, jaz@ofbiz.org
Subject: Re: Result Set Cursor Patch
In-Reply-To: <409302AC.6030807@opencloud.com>
References: <AC8D227A-9AB7-11D8-A094-000A95DA1A7C@ofbiz.org> <Pine.BSO.4.56.0404301035120.23452@leary.csoft.net> <B3BDBEB6-9ABF-11D8-A094-000A95DA1A7C@ofbiz.org> <Pine.BSO.4.56.0404301115170.23452@leary.csoft.net> <CDF53B82-9AC2-11D8-A094-000A95DA1A7C@ofbiz.org> <Pine.BSO.4.56.0404301128280.15995@leary.csoft.net> <AC9E43EA-9AC7-11D8-A094-000A95DA1A7C@ofbiz.org> <164902F2-9AE8-11D8-A094-000A95DA1A7C@ofbiz.org> <4092DAE1.5020500@opencloud.com> <53AED150-9B0C-11D8-A094-000A95DA1A7C@ofbiz.org> <409302AC.6030807@opencloud.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