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 49EFC9FA5FC for ; Wed, 21 Jun 2006 22:42:46 -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 21292-03 for ; Wed, 21 Jun 2006 22:42:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id A28D99FB0D1 for ; Wed, 21 Jun 2006 22:42:40 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [131.203.101.226]) by svr4.postgresql.org (Postfix) with ESMTP id 681FD5AFAC0 for ; Wed, 21 Jun 2006 22:55:52 +0000 (GMT) Received: from 221x253x225x162.ap221.ftth.ucom.ne.jp ([221.253.225.162] helo=[192.168.1.171]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1FtBYv-0000Es-6W; Thu, 22 Jun 2006 10:52:41 +1200 Message-ID: <4499CDB3.7040007@opencloud.com> Date: Thu, 22 Jun 2006 07:52:35 +0900 From: Oliver Jowett User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: Sebastiaan van Erk Cc: pgsql-jdbc@postgresql.org Subject: Re: Limit vs setMaxRows issue References: <44990D57.9070506@sebster.com> In-Reply-To: <44990D57.9070506@sebster.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/80 X-Sequence-Number: 15360 Sebastiaan van Erk wrote: > 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? 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.. -O