pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedResult Set Cursor Patch
27+ messages / 6 participants
[nested] [flat]
* Result Set Cursor Patch
@ 2004-04-30 15:04 Andy Zeneski <jaz@ofbiz.org>
0 siblings, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-04-30 15:04 UTC (permalink / raw)
To: pgsql-jdbc
I am not sure if this is the right place, or if the pgsql-patches list
is where this should go, since the CVS repositories are now in
different locations, I hoped this would be the right area.
Attached is a patch against the current CVS head for added support for
cursors in result set.
The reason for this patch I needed to iterate over a very large result
set, at first I was using PGSQL 7.3.x and the query crashed each time.
I believe out of memory errors were the cause. Later I realized that
the entire result set was being sent over, this was several millions of
rows.
I upgraded to PGSQL 7.4.2 since I saw it has support for cursors in
result sets, but it didn't work with my code. The problem was, I would
jump to last() and obtain the row for the total count, then jump back
to first() to begin my iteration. When setting the fetch size to 50, it
would only report 50 rows total. The last(), first(), absolute()
methods only looked at the current 'chunk' of rows. I think this may
have been a bug since later it appears that when scrollable was set it
was supposed to ignore the fetch size and grab all rows. This just will
not do.
This patch implements the absolute() method, using the cursor. The code
which checks for scrollable now creates the cursor with the SCROLL
keyword rather then avoiding cursors all together.
The patch passes the entire test suite, and I added a new test to test
absolute positioning. I am happy to answer any questions, and if anyone
sees any problems with the code please let me know. I think this will
be a great addition to PostgreSQL as I am having users switch to MySQL
MaxDB (SAPDB) due to performance problems. This patch solved a good
number of those problems!
Again, let me know if you see anything wrong and I will try to get it
corrected ASAP so this can get included with the next release!
Thanks,
-Andy
Attachments:
pgjdbc-cursor.patch.gz (application/x-gzip, 5.0K) download
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 15:43 Kris Jurka <books@ejurka.com>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 2 replies; 27+ messages in thread
From: Kris Jurka @ 2004-04-30 15:43 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
On Fri, 30 Apr 2004, Andy Zeneski wrote:
> I am not sure if this is the right place, or if the pgsql-patches list
> is where this should go, since the CVS repositories are now in
> different locations, I hoped this would be the right area.
This is the place for all things JDBC.
> Attached is a patch against the current CVS head for added support for
> cursors in result set.
>
> The patch passes the entire test suite, and I added a new test to test
> absolute positioning.
Some more tests for the other wrappers you have made around absolute and
other fetching methods would be nice (previous, relative, last, ...).
> Again, let me know if you see anything wrong and I will try to get it
> corrected ASAP so this can get included with the next release!
This patch does not support updateable ResultSets (deleteRow, insertRow),
but doesn't do anything to prevent a cursor from being used in that case.
Kris Jurka
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 16:01 Andy Zeneski <jaz@ofbiz.org>
parent: Kris Jurka <books@ejurka.com>
1 sibling, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-04-30 16:01 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
On Apr 30, 2004, at 11:43 AM, Kris Jurka wrote:
>
> Some more tests for the other wrappers you have made around absolute
> and
> other fetching methods would be nice (previous, relative, last, ...).
Sure, I was thinking of that myself. Since most of the code goes around
absolute() that was the primary one I wanted to make sure was tested.
But I can add some more.
> This patch does not support updateable ResultSets (deleteRow,
> insertRow),
> but doesn't do anything to prevent a cursor from being used in that
> case.
I don't recall changing this, if it previously prevented the cursor
from being used on update, then it should still be the same. I will
look into this and get it fixed. I don't think PostgreSQL supports
updateable cursors, so should the JDBC driver throw an exception if you
try to use updateable with a fetch size > 0, or should it avoid the
cursor and hope it can handle the results?
-Andy
Attachments:
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 16:14 Andy Zeneski <jaz@ofbiz.org>
parent: Kris Jurka <books@ejurka.com>
1 sibling, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-04-30 16:14 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Kris,
Does JDBC1 support CONCUR_UPDATABLE or just CONCUR_READ_ONLY?
-Andy
On Apr 30, 2004, at 11:43 AM, Kris Jurka wrote:
> This patch does not support updateable ResultSets (deleteRow,
> insertRow),
> but doesn't do anything to prevent a cursor from being used in that
> case.
>
> Kris Jurka
>
Attachments:
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 16:18 Kris Jurka <books@ejurka.com>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 1 reply; 27+ messages in thread
From: Kris Jurka @ 2004-04-30 16:18 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
On Fri, 30 Apr 2004, Andy Zeneski wrote:
>
> On Apr 30, 2004, at 11:43 AM, Kris Jurka wrote:
>
> > This patch does not support updateable ResultSets (deleteRow,
> > insertRow),
> > but doesn't do anything to prevent a cursor from being used in that
> > case.
>
> I don't recall changing this, if it previously prevented the cursor
> from being used on update, then it should still be the same. I will
> look into this and get it fixed. I don't think PostgreSQL supports
> updateable cursors, so should the JDBC driver throw an exception if you
> try to use updateable with a fetch size > 0, or should it avoid the
> cursor and hope it can handle the results?
>
You didn't, but before a scrollable updateable resultset would fetch all
the rows so it could manipulate them. With a cursor based method you will
be discarding the changes when moving to a new block and when refetching
you won't see them because the cursor won't pick up the changes. The
scrollable updateable case must fall back to fetching all rows instead of
throwing an exception because so many people are already using it.
Kris Jurka
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 16:20 Kris Jurka <books@ejurka.com>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 0 replies; 27+ messages in thread
From: Kris Jurka @ 2004-04-30 16:20 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
On Fri, 30 Apr 2004, Andy Zeneski wrote:
> Kris,
>
> Does JDBC1 support CONCUR_UPDATABLE or just CONCUR_READ_ONLY?
It doesn't know the difference. These constants were only introduced in
JDBC2, but all of ResultSet.updateXXX methods are JDBC2 so effectively all
JDBC1 resultsets are readonly.
Kris Jurka
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 16:24 Andy Zeneski <jaz@ofbiz.org>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-04-30 16:24 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
We are talking about concurrency right, not scroll type. The problem
will be not when the result set is scrollable, but rather then the
concurrency is updatable. Is this correct? If so, I have this fixed, I
am adding some test cases now and will send over a new patch.
-Andy
On Apr 30, 2004, at 12:18 PM, Kris Jurka wrote:
>
>
> You didn't, but before a scrollable updateable resultset would fetch
> all
> the rows so it could manipulate them. With a cursor based method you
> will
> be discarding the changes when moving to a new block and when
> refetching
> you won't see them because the cursor won't pick up the changes. The
> scrollable updateable case must fall back to fetching all rows instead
> of
> throwing an exception because so many people are already using it.
>
> Kris Jurka
Attachments:
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 16:29 Kris Jurka <books@ejurka.com>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 1 reply; 27+ messages in thread
From: Kris Jurka @ 2004-04-30 16:29 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
On Fri, 30 Apr 2004, Andy Zeneski wrote:
> We are talking about concurrency right, not scroll type. The problem
> will be not when the result set is scrollable, but rather then the
> concurrency is updatable. Is this correct? If so, I have this fixed, I
> am adding some test cases now and will send over a new patch.
Right, well it's both because you can have a forward only updateable
resultset use a cursor because it never has to refetch, but the scrollable
case causes problems.
Kris Jurka
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 16:58 Andy Zeneski <jaz@ofbiz.org>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-04-30 16:58 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
I expect this should take care of that issue.
-Andy
On Apr 30, 2004, at 12:29 PM, Kris Jurka wrote:
>>
>> concurrency is updatable. Is this correct? If so, I have this fixed, I
>> am adding some test cases now and will send over a new patch.
>
> Right, well it's both because you can have a forward only updateable
> resultset use a cursor because it never has to refetch, but the
> scrollable
> case causes problems.
>
> Kris Jurka
Attachments:
pgjdbc-cursor.patch.gz (application/x-gzip, 5.8K) download
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 20:51 Andy Zeneski <jaz@ofbiz.org>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-04-30 20:51 UTC (permalink / raw)
To: pgsql-jdbc
Please let me know if there is anything else which would prevent this
from getting into CVS. Also, if all is good, could you please let me
know when has been committed so I can update my local tree.
-Andy
On Apr 30, 2004, at 12:58 PM, Andy Zeneski wrote:
> I expect this should take care of that issue.
>
> -Andy
>
> <pgjdbc-cursor.patch.gz>
>
> On Apr 30, 2004, at 12:29 PM, Kris Jurka wrote:
>
>>>
>>> concurrency is updatable. Is this correct? If so, I have this fixed,
>>> I
>>> am adding some test cases now and will send over a new patch.
>>
>> Right, well it's both because you can have a forward only updateable
>> resultset use a cursor because it never has to refetch, but the
>> scrollable
>> case causes problems.
>>
>> Kris Jurka
Attachments:
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-04-30 23:01 Oliver Jowett <oliver@opencloud.com>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 1 reply; 27+ messages in thread
From: Oliver Jowett @ 2004-04-30 23:01 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
Andy Zeneski wrote:
> Please let me know if there is anything else which would prevent this
> from getting into CVS. Also, if all is good, could you please let me
> know when has been committed so I can update my local tree.
A few comments from looking at the patch..
resultSetSize() does a number of FETCH ABSOLUTEs, throwing away the
results, and then backtracking when it reaches a row that doesn't exist.
A better strategy might be to use MOVE FORWARD ALL and examine the
rowcount in the returned command tag.
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"?
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)
I have a number of code style comments too, let me know if you'd like
the gory details :)
-O
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-01 01:10 Andy Zeneski <jaz@ofbiz.org>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-05-01 01:10 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc
>
> resultSetSize() does a number of FETCH ABSOLUTEs, throwing away the
> results, and then backtracking when it reaches a row that doesn't
> exist. A better strategy might be to use MOVE FORWARD ALL and examine
> the rowcount in the returned command tag.
>
Nice. I didn't know about MOVE. I have re-coded the size method to use
this pattern. Much better. I wish I had know about that before, I only
use SQL92 standard in my code but this is perfect for here. Thanks!
> 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.
> 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?
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?
> I have a number of code style comments too, let me know if you'd like
> the gory details :)
>
I usually stick to the Sun standards with 4 spaces for tabs. I noticed
that in this code there were a lot of different styles being used,
probably from different people making changes. I assumed that a
convention was not official. If there is a certain style that you would
like me to use let me know, if you like I can let IDEA just reformat
everything based on Sun standards, but that would be a big patch.
-Andy
Attachments:
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-01 01:51 Oliver Jowett <oliver@opencloud.com>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 0 replies; 27+ messages in thread
From: Oliver Jowett @ 2004-05-01 01:51 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
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
^ permalink raw reply [nested|flat] 27+ messages in thread
* Result Set Cursor Patch
@ 2004-05-04 16:59 Andy Zeneski <jaz@ofbiz.org>
0 siblings, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-05-04 16:59 UTC (permalink / raw)
To: pgsql-jdbc
I submitted an updated patch to this list on yesterday, but I never saw
my post come through. Did I just miss it or was it lost in transit
somewhere?
-Andy
Attachments:
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-04 17:35 Kris Jurka <books@ejurka.com>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 2 replies; 27+ messages in thread
From: Kris Jurka @ 2004-05-04 17:35 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
On Tue, 4 May 2004, Andy Zeneski wrote:
> I submitted an updated patch to this list on yesterday, but I never saw
> my post come through. Did I just miss it or was it lost in transit
> somewhere?
>
I haven't seen it and it's not in the archives. If it was large it could
have gotten killed. The list has a size limit somewhere in the 30-50k
range.
Kris Jurka
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-05 13:49 Tom Lane <tgl@sss.pgh.pa.us>
parent: Kris Jurka <books@ejurka.com>
1 sibling, 0 replies; 27+ messages in thread
From: Tom Lane @ 2004-05-05 13:49 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: Andy Zeneski <jaz@ofbiz.org>; pgsql-jdbc
Kris Jurka <books@ejurka.com> writes:
> I haven't seen it and it's not in the archives. If it was large it could
> have gotten killed. The list has a size limit somewhere in the 30-50k
> range.
I believe pgsql-patches has a larger size limit. Also, consider
compressing the attachment if that will get you under 30K ...
BTW, you can set majordomo to notify you if it delays or drops a
message. I think this is not on by default for some reason.
regards, tom lane
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-05 16:58 Andy Zeneski <jaz@ofbiz.org>
parent: Kris Jurka <books@ejurka.com>
1 sibling, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-05-05 16:58 UTC (permalink / raw)
To: pgsql-jdbc; +Cc: Kris Jurka <books@ejurka.com>
Kris,
Here it is again, I think my IDE reformatted a few classes which caused
this patch to be bigger then it needed to be. Here it is in its current
state.
I took the suggestions from the list and implemented the movement of
position using the MOVE command. This made finding the result set size
MUCH easier. In addition, I moved all the code related to chunks into a
new class called ResultChunk which lives in core.
Attached is a tarball which contains the new file as well as the patch.
This patch uses diff -c rather then diff -u as it was brought to my
attention as being the preferred format for this project. Let me know
if this is not correct.
If the formatting is major problem, I can attempt to reformat it to
desired settings. I will need to know what the "preferred" way is. I've
noticed there are several different formats used within these classes,
I could easily run the tree though Jacobe and clean it up. However,
that may be too big for the list. :)
There is partial support for reverse fetching in this patch, but it
does not work yet. In this version it is completely disabled so even if
reverse is requested it will ignore the request and use forward
fetching instead.
I will fix this when I have some extra time. I don't think the current
code supports reverse fetching either, so I don't think any current
functionality is lost.
The code attached does pass the entire test suite without problem.
Please let me know if there are any problems.
-Andy
On May 4, 2004, at 1:35 PM, Kris Jurka wrote:
>
>
> On Tue, 4 May 2004, Andy Zeneski wrote:
>
>> I submitted an updated patch to this list on yesterday, but I never
>> saw
>> my post come through. Did I just miss it or was it lost in transit
>> somewhere?
>>
>
> I haven't seen it and it's not in the archives. If it was large it
> could
> have gotten killed. The list has a size limit somewhere in the 30-50k
> range.
>
> Kris Jurka
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if
> your
> joining column's datatypes do not match
Attachments:
cursor-impl.tar.bz2 (application/octet-stream, 25.3K) download
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-05 19:46 Kris Jurka <books@ejurka.com>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 3 replies; 27+ messages in thread
From: Kris Jurka @ 2004-05-05 19:46 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
On Wed, 5 May 2004, Andy Zeneski wrote:
> Kris,
>
> Here it is again, I think my IDE reformatted a few classes which caused
> this patch to be bigger then it needed to be. Here it is in its current
> state.
>
> If the formatting is major problem, I can attempt to reformat it to
> desired settings. I will need to know what the "preferred" way is. I've
> noticed there are several different formats used within these classes,
> I could easily run the tree though Jacobe and clean it up. However,
> that may be too big for the list. :)
The formatting is an issue. Yes, the code is formatted differently all
over the driver, but now is not the time to fix that. There are too many
outstanding patches that will conflict with these whitespace changes to
try and do something about that now. I aim to reindent/reformat at the
start of 7.5 beta when there shouldn't be many outstanding patches or
active development.
Also just trying to read your patch is difficult because it is impossible
to tell if a real change is mixed in with a whitespace change. Could you
resubmit this patch as just your changes.
Kris Jurka
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-05 20:15 Barry Lind <blind@xythos.com>
parent: Kris Jurka <books@ejurka.com>
2 siblings, 1 reply; 27+ messages in thread
From: Barry Lind @ 2004-05-05 20:15 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
Or add a -w to your diff to ignore whitespace differences.
--Barry
Kris Jurka wrote:
>
> On Wed, 5 May 2004, Andy Zeneski wrote:
>
>
>>Kris,
>>
>>Here it is again, I think my IDE reformatted a few classes which caused
>>this patch to be bigger then it needed to be. Here it is in its current
>>state.
>>
>>If the formatting is major problem, I can attempt to reformat it to
>>desired settings. I will need to know what the "preferred" way is. I've
>>noticed there are several different formats used within these classes,
>>I could easily run the tree though Jacobe and clean it up. However,
>>that may be too big for the list. :)
>
>
> The formatting is an issue. Yes, the code is formatted differently all
> over the driver, but now is not the time to fix that. There are too many
> outstanding patches that will conflict with these whitespace changes to
> try and do something about that now. I aim to reindent/reformat at the
> start of 7.5 beta when there shouldn't be many outstanding patches or
> active development.
>
> Also just trying to read your patch is difficult because it is impossible
> to tell if a real change is mixed in with a whitespace change. Could you
> resubmit this patch as just your changes.
>
> Kris Jurka
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-05 21:04 Andy Zeneski <jaz@ofbiz.org>
parent: Barry Lind <blind@xythos.com>
0 siblings, 0 replies; 27+ messages in thread
From: Andy Zeneski @ 2004-05-05 21:04 UTC (permalink / raw)
To: Barry Lind <blind@xythos.com>; +Cc: pgsql-jdbc
No when the the formatting got real messy, I just told IDEA to reformat
the entire class. Ended up doing that for a few of them. That changed a
lot of lines. I'll need to figure out what is different. This will
probably take a while to do.
-Andy
On May 5, 2004, at 4:15 PM, Barry Lind wrote:
> Or add a -w to your diff to ignore whitespace differences.
>
> --Barry
>
> Kris Jurka wrote:
>> On Wed, 5 May 2004, Andy Zeneski wrote:
>>> Kris,
>>>
>>> Here it is again, I think my IDE reformatted a few classes which
>>> caused this patch to be bigger then it needed to be. Here it is in
>>> its current state.
>>>
>>> If the formatting is major problem, I can attempt to reformat it to
>>> desired settings. I will need to know what the "preferred" way is.
>>> I've noticed there are several different formats used within these
>>> classes, I could easily run the tree though Jacobe and clean it up.
>>> However, that may be too big for the list. :)
>> The formatting is an issue. Yes, the code is formatted differently
>> all over the driver, but now is not the time to fix that. There are
>> too many outstanding patches that will conflict with these whitespace
>> changes to try and do something about that now. I aim to
>> reindent/reformat at the start of 7.5 beta when there shouldn't be
>> many outstanding patches or active development.
>> Also just trying to read your patch is difficult because it is
>> impossible to tell if a real change is mixed in with a whitespace
>> change. Could you resubmit this patch as just your changes.
>> Kris Jurka
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 9: the planner will ignore your desire to choose an index scan if
>> your
>> joining column's datatypes do not match
Attachments:
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-05 23:06 Oliver Jowett <oliver@opencloud.com>
parent: Kris Jurka <books@ejurka.com>
2 siblings, 2 replies; 27+ messages in thread
From: Oliver Jowett @ 2004-05-05 23:06 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Kris Jurka wrote:
> The formatting is an issue. Yes, the code is formatted differently all
> over the driver, but now is not the time to fix that. There are too many
> outstanding patches that will conflict with these whitespace changes to
> try and do something about that now. I aim to reindent/reformat at the
> start of 7.5 beta when there shouldn't be many outstanding patches or
> active development.
Are we still tracking the main tree's release cycle then? I thought part
of the reason for moving to gborg was because the JDBC driver's release
cycle didn't match the main tree's release cycle well?
I have a large stack of not-yet-ready-for-prime-time v3 protocol changes
that I'd like to get in at some point -- but I don't want to get bitten
by "we're in beta, this is too big to apply". Are we planning on a
code/feature freeze or similar, tracking whatever 7.5 is doing?
Also, now that the driver is separate from the main code tree, maybe
it'd be a good idea when reindenting to use more "normal" (for java
anyway) indentation rules -- e.g. use either all spaces or spaces and
8-character tabs when indenting. The current 4-character tabs rule is
fairly unusual. That'd make driver editing easier across a range of
IDEs; sure, I have my xemacs settings that play nicely with the current
scheme, but it's a barrier to entry for anyone who hasn't worked on the
driver before.
-O
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-05 23:55 Brian Olson <bolson@bolson.org>
parent: Oliver Jowett <oliver@opencloud.com>
1 sibling, 1 reply; 27+ messages in thread
From: Brian Olson @ 2004-05-05 23:55 UTC (permalink / raw)
To: pgsql-jdbc
This outsider/new-guy-on-the-list thinks "4 space" tabs are great. I think
it's very portable because if a file is indented with all tabs then
someone can set their editor to render that however they like: 2, 4, 8, e,
Pi, etc. "spaces".
4 space + 8-space-tabs is the least portable. Everyone has to configure
their editor exactly alike.
all spaces is portable, everyone gets the same thing, but on the down
side, everyone gets the same thing.
Of course, that's just my opinion, I could be wrong.
Brian Olson
http://bolson.org/
On Thu, 6 May 2004, Oliver Jowett wrote:
> Also, now that the driver is separate from the main code tree, maybe
> it'd be a good idea when reindenting to use more "normal" (for java
> anyway) indentation rules -- e.g. use either all spaces or spaces and
> 8-character tabs when indenting. The current 4-character tabs rule is
> fairly unusual. That'd make driver editing easier across a range of
> IDEs; sure, I have my xemacs settings that play nicely with the current
> scheme, but it's a barrier to entry for anyone who hasn't worked on the
> driver before.
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-06 00:41 Barry Lind <blind@xythos.com>
parent: Oliver Jowett <oliver@opencloud.com>
1 sibling, 1 reply; 27+ messages in thread
From: Barry Lind @ 2004-05-06 00:41 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: Kris Jurka <books@ejurka.com>; pgsql-jdbc
Oliver Jowett wrote:
> Are we still tracking the main tree's release cycle then? I thought part
> of the reason for moving to gborg was because the JDBC driver's release
> cycle didn't match the main tree's release cycle well?
>
> I have a large stack of not-yet-ready-for-prime-time v3 protocol changes
> that I'd like to get in at some point -- but I don't want to get bitten
> by "we're in beta, this is too big to apply". Are we planning on a
> code/feature freeze or similar, tracking whatever 7.5 is doing?
>
I suspect we are trying to track the server release schedule. 7.5 looks
like it might be the first server release in a while that didn't require
changes to the jdbc driver to remain compatible with it. So I don't
know of a reason right now that would force a new jdbc version at the
same time as 7.5 of the server, however I think it is a good idea.
As for the move to gborg, the rational of different release cycles was
one argument made by those forcing the jdbc driver out of the base
source tree. Jdbc was moved to gborg not by choice but by mandate.
--Barry
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-07 00:43 Oliver Jowett <oliver@opencloud.com>
parent: Brian Olson <bolson@bolson.org>
0 siblings, 0 replies; 27+ messages in thread
From: Oliver Jowett @ 2004-05-07 00:43 UTC (permalink / raw)
To: Brian Olson <bolson@bolson.org>; +Cc: pgsql-jdbc
Brian Olson wrote:
> This outsider/new-guy-on-the-list thinks "4 space" tabs are great. I think
> it's very portable because if a file is indented with all tabs then
> someone can set their editor to render that however they like: 2, 4, 8, e,
> Pi, etc. "spaces".
This only works if you only ever indent in strict multiples of a
tabwidth and are consistent about only ever using tabs. In practice,
this doesn't happen -- you'll get spaces appearing pretty fast. Witness
the current driver, where in theory only tabs should be being used, but
in practice there are lots of spaces used to indent. Also consider cases
like this, assuming 2-space tabs on the lefthand side:
if (condition) { // Comment 1
code; // Comment 2
} // Comment 3
With 4 space tabs we get:
if (condition) { // Comment 1
code; // Comment 2
} // Comment 3
Oops, those comments don't nicely line up any more. You can't fix it
using tabs to align the comments either, since the indenting you need on
a particular line depends on the line length and isn't necessarily a
multiple of the tab width.
> 4 space + 8-space-tabs is the least portable. Everyone has to configure
> their editor exactly alike.
Yes, mixing spaces and tabs makes life difficult (especially if you're
editing python code!). This is essentially the same case as the current
code (both spaces and 4-space-tabs are used, although tabs-only is
mandated).
> all spaces is portable, everyone gets the same thing, but on the down
> side, everyone gets the same thing.
This is what I prefer because it's hard to get wrong. And personally I
think that the *goal* is that everyone sees the same thing for a
particular bit of code.
And it makes 'diff' and 'less' produce more readable output, too :)
There's a pretty good summary of the issues at
http://www.jwz.org/doc/tabs-vs-spaces.html. Some conclusions from that doc:
> My opinion is that the best way to solve the technical issues is to
> mandate that the ASCII #9 TAB character never appear in disk files:
> program your editor to expand TABs to an appropriate number of spaces
> before writing the lines to disk. That simplifies matters greatly, by
> separating the technical issues of #2 and #3 from the religious issue of
> #1.
> I just care that two people editing the same file use the same
> interpretations, and that it's possible to look at a file and know what
> interpretation of the TAB character was used, because otherwise it's
> just impossible to read.
-O
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-07 05:46 Kris Jurka <books@ejurka.com>
parent: Barry Lind <blind@xythos.com>
0 siblings, 0 replies; 27+ messages in thread
From: Kris Jurka @ 2004-05-07 05:46 UTC (permalink / raw)
To: Barry Lind <blind@xythos.com>; +Cc: Oliver Jowett <oliver@opencloud.com>; pgsql-jdbc
On Wed, 5 May 2004, Barry Lind wrote:
>
>
> Oliver Jowett wrote:
> > Are we still tracking the main tree's release cycle then? I thought part
> > of the reason for moving to gborg was because the JDBC driver's release
> > cycle didn't match the main tree's release cycle well?
> >
>
> I suspect we are trying to track the server release schedule. 7.5 looks
> like it might be the first server release in a while that didn't require
> changes to the jdbc driver to remain compatible with it. So I don't
> know of a reason right now that would force a new jdbc version at the
> same time as 7.5 of the server, however I think it is a good idea.
>
Yes, continuing to track the server releases is the plan as I understand
it. I would venture that we don't need to stick to their feature freeze
date which is June 1st as best as I can tell from a long and complicated
hackers discussion. Server betas tend to take forever and I don't think
we need that kind of time to smooth out any JDBC issues. Assuming a
minimum two month server freeze->release time frame, I would be
comfortable with a July 1st freeze for the JDBC driver. Thoughts?
Kris Jurka
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-11 16:57 Andy Zeneski <jaz@ofbiz.org>
parent: Kris Jurka <books@ejurka.com>
2 siblings, 1 reply; 27+ messages in thread
From: Andy Zeneski @ 2004-05-11 16:57 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Kris,
Here is that patch again, correct without any formatting or whitespace
changes (white space was ignored in the diff). Let me know if this is
better then the last one.
-Andy
On May 5, 2004, at 3:46 PM, Kris Jurka wrote:
>
>
> On Wed, 5 May 2004, Andy Zeneski wrote:
>
>> Kris,
>>
>> Here it is again, I think my IDE reformatted a few classes which
>> caused
>> this patch to be bigger then it needed to be. Here it is in its
>> current
>> state.
>>
>> If the formatting is major problem, I can attempt to reformat it to
>> desired settings. I will need to know what the "preferred" way is.
>> I've
>> noticed there are several different formats used within these classes,
>> I could easily run the tree though Jacobe and clean it up. However,
>> that may be too big for the list. :)
>
> The formatting is an issue. Yes, the code is formatted differently all
> over the driver, but now is not the time to fix that. There are too
> many
> outstanding patches that will conflict with these whitespace changes to
> try and do something about that now. I aim to reindent/reformat at the
> start of 7.5 beta when there shouldn't be many outstanding patches or
> active development.
>
> Also just trying to read your patch is difficult because it is
> impossible
> to tell if a real change is mixed in with a whitespace change. Could
> you
> resubmit this patch as just your changes.
>
> Kris Jurka
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if
> your
> joining column's datatypes do not match
Attachments:
cursor-impl.tar.gz (application/x-gzip, 10.8K) download
smime.p7s (application/pkcs7-signature, 2.0K) download
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Result Set Cursor Patch
@ 2004-05-24 06:38 Kris Jurka <books@ejurka.com>
parent: Andy Zeneski <jaz@ofbiz.org>
0 siblings, 0 replies; 27+ messages in thread
From: Kris Jurka @ 2004-05-24 06:38 UTC (permalink / raw)
To: Andy Zeneski <jaz@ofbiz.org>; +Cc: pgsql-jdbc
On Tue, 11 May 2004, Andy Zeneski wrote:
> Here is that patch again, correct without any formatting or whitespace
> changes (white space was ignored in the diff). Let me know if this is
> better then the last one.
>
This is much better, but there are still a fair number of inconsequential
changes like renaming this_row and other variables. If we had
some naming standards that you were matching to, or you were making
everything in one localized area match I wouldn't object, but I can't say
I understand the name changes. Anyway that's a minor issue at this point,
so lets get to the heart of the matter.
The JDBC driver's goal is compatibility for the current version and the
previous two releases. Two key features this depends on were introduced
in 7.4: ABSOLUTE cursor positioning and the SCROLL keyword actually
guaranteeing a scrollable cursor in all situations. Ideally we could
retain the current FORWARD_ONLY requirement for 7.3 servers.
I notice ResultSetChunk has get/setFetchSize, but they are unused and lack
the checking provided in the AbstractJdbc2ResultSet versions.
I tried creating three 100 row tables which in an unconstrained join
produce a million rows and testing some things.
rs.absolute(44000000); // past the end of the result
LOG: statement: DECLARE JDBC_CURS_1 SCROLL CURSOR FOR SELECT a,b,c FROM
t1,t2,t3 ; FETCH FORWARD 3 FROM JDBC_CURS_1
LOG: duration: 1.425 ms
LOG: statement: MOVE ABSOLUTE 43999999 IN JDBC_CURS_1
LOG: duration: 3565.519 ms
LOG: statement: FETCH FORWARD 3 FROM JDBC_CURS_1
LOG: duration: 2.236 ms
LOG: statement: MOVE FORWARD ALL IN JDBC_CURS_1
LOG: duration: 2.134 ms
LOG: statement: MOVE ABSOLUTE 0 IN JDBC_CURS_1
LOG: duration: 2.139 ms
LOG: statement: MOVE FORWARD ALL IN JDBC_CURS_1
LOG: duration: 1312.637 ms
LOG: statement: MOVE ABSOLUTE 43999999 IN JDBC_CURS_1
LOG: duration: 2.135 ms
This jumps back to zero and then to the end again for some reason costing
us 1.3 seconds in this test.
In general something seems wrong. Testing using previous() with a forward
fetch direction I see:
rs.absolute();
while (rs.previous()) ;
LOG: statement: DECLARE JDBC_CURS_1 SCROLL CURSOR FOR SELECT a,b,c FROM
t1,t2,t3 ; FETCH FORWARD 3 FROM JDBC_CURS_1
LOG: duration: 1.441 ms
LOG: statement: MOVE ABSOLUTE 19 IN JDBC_CURS_1
LOG: duration: 0.394 ms
LOG: statement: FETCH FORWARD 3 FROM JDBC_CURS_1
LOG: duration: 0.349 ms
LOG: statement: MOVE ABSOLUTE 0 IN JDBC_CURS_1
LOG: duration: 0.225 ms
LOG: statement: MOVE FORWARD ALL IN JDBC_CURS_1
LOG: duration: 3550.779 ms
LOG: statement: MOVE ABSOLUTE 22 IN JDBC_CURS_1
LOG: duration: 2.287 ms
LOG: statement: MOVE ABSOLUTE 18 IN JDBC_CURS_1
LOG: duration: 2.164 ms
LOG: statement: FETCH FORWARD 3 FROM JDBC_CURS_1
LOG: duration: 2.231 ms
LOG: statement: MOVE ABSOLUTE 17 IN JDBC_CURS_1
LOG: duration: 2.156 ms
LOG: statement: FETCH FORWARD 3 FROM JDBC_CURS_1
LOG: duration: 2.268 ms
This strangely jumps back and forward after the first fetch and kills
performance for this query.
The way that previous() currently works will be a real downer for many
people, especially with a reasonably large fetch size. While FETCH
BACKWARD is ideal, a stopgap solution would be to MOVE back and fetch
forward which looks like it might be easier with your current code setup.
For this particular case (especially because people probably aren't
setting fetch direction) I would disagree with your defaulting of
fetchSize to 1000 instead of it's previous 0 meaning no cursor fetching.
Finally I notice that the cursor is not closed when either the ResultSet
or Statement are closed. This wasn't really a problem with non-scrolling
cursors, but now with the possibility of consuming significant server side
resources this is a necessity.
Kris Jurka
^ permalink raw reply [nested|flat] 27+ messages in thread
end of thread, other threads:[~2004-05-24 06:38 UTC | newest]
Thread overview: 27+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-04-30 15:04 Result Set Cursor Patch Andy Zeneski <jaz@ofbiz.org>
2004-04-30 15:43 ` Kris Jurka <books@ejurka.com>
2004-04-30 16:01 ` Andy Zeneski <jaz@ofbiz.org>
2004-04-30 16:18 ` Kris Jurka <books@ejurka.com>
2004-04-30 16:24 ` Andy Zeneski <jaz@ofbiz.org>
2004-04-30 16:29 ` Kris Jurka <books@ejurka.com>
2004-04-30 16:58 ` Andy Zeneski <jaz@ofbiz.org>
2004-04-30 20:51 ` Andy Zeneski <jaz@ofbiz.org>
2004-04-30 23:01 ` Oliver Jowett <oliver@opencloud.com>
2004-05-01 01:10 ` Andy Zeneski <jaz@ofbiz.org>
2004-05-01 01:51 ` Oliver Jowett <oliver@opencloud.com>
2004-04-30 16:14 ` Andy Zeneski <jaz@ofbiz.org>
2004-04-30 16:20 ` Kris Jurka <books@ejurka.com>
2004-05-04 16:59 Result Set Cursor Patch Andy Zeneski <jaz@ofbiz.org>
2004-05-04 17:35 ` Kris Jurka <books@ejurka.com>
2004-05-05 13:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-05-05 16:58 ` Andy Zeneski <jaz@ofbiz.org>
2004-05-05 19:46 ` Kris Jurka <books@ejurka.com>
2004-05-05 20:15 ` Barry Lind <blind@xythos.com>
2004-05-05 21:04 ` Andy Zeneski <jaz@ofbiz.org>
2004-05-05 23:06 ` Oliver Jowett <oliver@opencloud.com>
2004-05-05 23:55 ` Brian Olson <bolson@bolson.org>
2004-05-07 00:43 ` Oliver Jowett <oliver@opencloud.com>
2004-05-06 00:41 ` Barry Lind <blind@xythos.com>
2004-05-07 05:46 ` Kris Jurka <books@ejurka.com>
2004-05-11 16:57 ` Andy Zeneski <jaz@ofbiz.org>
2004-05-24 06:38 ` Kris Jurka <books@ejurka.com>
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