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 4A5589FA5BA for ; Thu, 22 Jun 2006 13:36:37 -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 05965-08 for ; Thu, 22 Jun 2006 13:36:22 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail2.yozons.com (mail2.yozons.com [63.251.168.97]) by postgresql.org (Postfix) with ESMTP id 649BC9FA2F0 for ; Thu, 22 Jun 2006 13:36:22 -0300 (ADT) Received: from [192.168.1.46] (pool-71-112-28-61.sttlwa.dsl-w.verizon.net [71.112.28.61]) (authenticated bits=0) by mail2.yozons.com (8.12.10/8.12.10) with ESMTP id k5MGaKxs012720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Jun 2006 09:36:20 -0700 Message-ID: <449AC711.6050401@computer.org> Date: Thu, 22 Jun 2006 09:36:33 -0700 From: David Wall User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Limit vs setMaxRows issue References: <44990D57.9070506@sebster.com> <4499CDB3.7040007@opencloud.com> In-Reply-To: <4499CDB3.7040007@opencloud.com> 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: 200606/94 X-Sequence-Number: 15374 What about the setFetchSize method? My impression is that using setFetchSize along with setMaxRows would do the trick on the back end as it resulted in the cursor mechanism that didn't retrieve the complete result set. Is that not the case in PG 8.1 (at least with the few caveats listed at http://jdbc.postgresql.org/documentation/81/query.html)? David > 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, the minimal implementation won't change query execution at > all and will just limit rows coming back out of the ResultSet.. It > might be nice to add LIMIT but that would require the driver to parse > query strings which gets very complicated and isn't going to catch all > the cases anyway. You'll be getting at least some improvement with the > existing driver because the whole resultset isn't being transferred > and processed, even if the plan is still assuming you will grab all > the data. > > If your queries need a LIMIT clause to get decent performance then > your safest bet is to add a LIMIT clause yourself. You can keep the > setMaxRows() as well if you like..