Skip site navigation (1) Skip section navigation (2)

Re: Limit vs setMaxRows issue

From: Kris Jurka <books(at)ejurka(dot)com>
To: Sebastiaan van Erk <sebster(at)sebster(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Limit vs setMaxRows issue
Date: 2006-06-21 16:00:06
Message-ID: Pine.BSO.4.63.0606211055020.7242@leary2.csoft.net (view raw or flat)
Thread:
Lists: pgsql-jdbc

On Wed, 21 Jun 2006, Sebastiaan van Erk wrote:

> I'm not 100% sure of what JDBC says about setMaxRows (it's kind of ambiguous 
> in the java doc, as usual), but as far as I can tell, if you call setMaxRows 
> on the prepared statement there is no way in to ever retrieve more than that 
> number of rows. If this is indeed the case, it seems to me that currently 
> there is a mismatch between the JDBC api and the postgresql api, and JDBC 
> should somehow tell postgres that this is a hard limit and it should not plan 
> for a second batch.
>
> Therefore, my question is: is this a bug? It is not feasable for me to add 
> LIMIT clauses to all the SQL queries in my code, so if this IS a bug, I hope 
> it can be fixed. If it is NOT a bug, is there an alternative workaround that 
> does not involve changing all of my sql statements?
>

I'm not sure how you would like the driver to tell the server that it 
doesn't want more than setMaxRows rows.  The defined API for this is using 
LIMIT in your sql query.  The driver cannot do this for you (at least 
without parsing your query) because the query may already have a LIMIT or 
it may be something like an INSERT into a VIEW that has a DO INSTEAD 
SELECT rule on it.  If you're suggesting that we extended the 
frontend/backend protocol to include this extra information than that's 
definitely a feature request, not a bug report.

Kris Jurka

In response to

Responses

pgsql-jdbc by date

Next:From: A.M.Date: 2006-06-21 16:10:22
Subject: Re: Limit vs setMaxRows issue
Previous:From: Sebastiaan van ErkDate: 2006-06-21 15:49:00
Subject: Re: Limit vs setMaxRows issue

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group