Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id A18569F969C for ; Sat, 11 Aug 2007 06:06:55 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 32187-10 for ; Sat, 11 Aug 2007 06:06:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from depesz.com (depesz.com [88.198.37.40]) by postgresql.org (Postfix) with ESMTP id A05349F9697 for ; Sat, 11 Aug 2007 06:06:49 -0300 (ADT) Received: from depesz by depesz.com with local (Exim 4.63) (envelope-from ) id 1IJmvk-0001N6-B6; Sat, 11 Aug 2007 11:06:44 +0200 Date: Sat, 11 Aug 2007 11:06:44 +0200 From: hubert depesz lubaczewski To: Rodrigo De =?utf-8?B?TGXDs24=?= Cc: Fernando Hevia , Kiran , pgsql-sql@postgresql.org Subject: Re: Best Fit SQL query statement Message-ID: <20070811090644.GA5255@depesz.com> Reply-To: depesz@depesz.com References: <20070810075949.GA31829@depesz.com> <00e101c7db86$51b3d8b0$8f01010a@iptel.com.ar> <20070810225953.GA28341@depesz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL=0.024, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200708/94 X-Sequence-Number: 29032 On Fri, Aug 10, 2007 at 08:13:46PM -0500, Rodrigo De León wrote: > On 8/10/07, hubert depesz lubaczewski wrote: > > unfortunatelly this query will be hard to optimize. > > Uh, how about > > SELECT MAX(t1) > FROM t1 > WHERE '9849' LIKE t1 || '%'; it will not help much as the main burden is the where clause, which is not indexable. depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) http://www.depesz.com/ - blog dla ciebie (i moje CV)