Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 318239FB339 for ; Fri, 31 Aug 2007 16:18:55 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 25160-02 for ; Fri, 31 Aug 2007 16:18:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mtao05.charter.net (mtao05.charter.net [209.225.8.179]) by postgresql.org (Postfix) with ESMTP id EFFCA9FB204 for ; Fri, 31 Aug 2007 16:18:49 -0300 (ADT) Received: from aarprv02.charter.net ([10.20.200.72]) by mtao05.charter.net (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070831191844.UOPA29426.mtao05.charter.net@aarprv02.charter.net>; Fri, 31 Aug 2007 15:18:44 -0400 Received: from [10.0.1.3] (really [66.188.165.91]) by aarprv02.charter.net with ESMTP id <20070831191844.CAXU495.aarprv02.charter.net@[10.0.1.3]>; Fri, 31 Aug 2007 15:18:44 -0400 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <373D2F52-E9CD-485A-9BF1-B019349FA5EC@seespotcode.net> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: How to influence the planner Date: Fri, 31 Aug 2007 14:18:36 -0500 To: Richard Ray X-Mailer: Apple Mail (2.752.2) X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/270 X-Sequence-Number: 29208 On Aug 31, 2007, at 13:32 , Richard Ray wrote: > "select * from t1 where length(bar) = 0;" runs about 2 minutes > "select * from t1 where length(bar) = 0 order by foo ;" ran until I > stopped it after about 20 minutes EXPLAIN ANALYZE will help you see what the planner is doing to produce the results. Have you recently ANALYZEd t1? If length(bar) = 0 is a common operation on this table, you might consider using an expression index on t1: create index t1_length_bar_idx on t1 (length(bar)); You might want to ask on the performance list as well, as this is right up their alley. Hope this gets you started on the right track. Michael Glaesemann grzm seespotcode net