X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 598E89FB2E2 for ; Tue, 11 Jul 2006 00:33:09 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 57207-07 for ; Tue, 11 Jul 2006 00:33:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [131.203.101.226]) by postgresql.org (Postfix) with ESMTP id 3C4BE9FB2A6 for ; Tue, 11 Jul 2006 00:33:03 -0300 (ADT) Received: from sony.opencloud.co.nz ([192.168.0.41]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1G08za-0004HH-HP; Tue, 11 Jul 2006 15:32:58 +1200 Message-ID: <44B3461F.1060408@opencloud.com> Date: Tue, 11 Jul 2006 15:33:03 +0900 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.8 (X11/20060502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Marc Herbert CC: pgsql-jdbc@postgresql.org Subject: Re: Limit vs setMaxRows issue References: <44990D57.9070506@sebster.com> <4499CDB3.7040007@opencloud.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/29 X-Sequence-Number: 15455 Marc Herbert wrote: > Oliver Jowett writes: > > >>It's not a bug. setMaxRows() is essentially a hint, there's certainly >>no requirement that the driver will go off and add LIMIT clauses to >>your query, > > > My reading of the JDBC javadoc and my excessive "pickiness" do not > agree with the word "hint" > > /** > * Sets the limit for the maximum number of rows that any > * ResultSet object can contain to the given number. > * If the limit is exceeded, the excess > * rows are silently dropped. > > > OK nothing ever tells you that the server has to behave optimally and > never compute anything useless. However in this case you know _for > sure_ that additional rows will be useless. I would assume that if the intent of the spec was "put LIMIT on the query", they would say that. As it stands all it does from an API point of view is change the behaviour of the ResultSet. Whether that does anything for efficiency is an implementation decision. The driver certainly behaves correctly according to the API, which was my point. There are other optimizations you can make that don't affect query execution at all -- for example, you know you only need to store the first N rows returned, not all of them. -O