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

Re: Limit vs setMaxRows issue

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Marc Herbert <Marc(dot)Herbert(at)continuent(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Limit vs setMaxRows issue
Date: 2006-07-11 06:38:09
Message-ID: 44B34751.7010704@opencloud.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Marc Herbert wrote:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> 
> 
>>No, it would take a protocol change to add such a thing out-of-line
>>(that is, not as a LIMIT clause in the query text).  The reason is that
>>the planning is done at PARSE time, or at the latest BIND time.  The
>>row limit field in the EXECUTE message comes far too late to affect the
>>query plan. 
> 
> 
> 
> If planning is done at time of creation of the PreparedStatement
> object (reminder: the example given above has no parameters), then the
> setMaxRows() call will come too late whatever is the protocol change.
> I mean: no protocol change can go back in time and "optimize" by not
> doing useless work already done.
> 
> Thanks in advance for pointing out my mistake(s) here.

We do not special-case the no-parameters case, so it's handled just like 
all the other cases: the query is parsed and planned immediately before 
execution. We also avoid an extra round-trip by doing it at that point.

If you're interested in the details of this, the driver source code is 
really your best reference..

-O

In response to

Responses

pgsql-jdbc by date

Next:From: Marc HerbertDate: 2006-07-11 09:48:51
Subject: Re: Limit vs setMaxRows issue
Previous:From: Oliver JowettDate: 2006-07-11 06:33:03
Subject: Re: Limit vs setMaxRows issue

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