Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 4B97D9FB327 for ; Fri, 31 Aug 2007 16:04:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 86691-02 for ; Fri, 31 Aug 2007 16:04:38 -0300 (ADT) X-Greylist: delayed 00:32:18.139014 by SQLgrey-1.7.5 Received: from itspmx3.state.ms.us (itspmx3.state.ms.us [205.144.225.69]) by postgresql.org (Postfix) with ESMTP id 13FB19F9CD6 for ; Fri, 31 Aug 2007 16:04:38 -0300 (ADT) Received: from itspmx3.state.ms.us (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id A851596C4 for ; Fri, 31 Aug 2007 13:32:20 -0500 (CDT) Received: from itspmx51.state.ms.us (itspmx51.state.ms.us [10.12.20.51]) by itspmx3.state.ms.us (Postfix) with ESMTP id 9A40296B7 for ; Fri, 31 Aug 2007 13:32:20 -0500 (CDT) Received: from itspmx51.state.ms.us (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id 63B355B15 for ; Thu, 31 Aug 2000 13:32:12 -0500 (CDT) Received: from rray.drdc.mstc.ms.gov (unknown [10.3.192.2]) by itspmx51.state.ms.us (Postfix) with ESMTP id 441DD5B14 for ; Thu, 31 Aug 2000 13:32:12 -0500 (CDT) Received: from rray.drdc.mstc.ms.gov (localhost.localdomain [127.0.0.1]) by rray.drdc.mstc.ms.gov (8.13.8/8.13.8) with ESMTP id l7VIWHDS031569 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 31 Aug 2007 13:32:17 -0500 Received: from localhost (rray@localhost) by rray.drdc.mstc.ms.gov (8.13.8/8.13.8/Submit) with ESMTP id l7VIWHxA031566 for ; Fri, 31 Aug 2007 13:32:17 -0500 X-Authentication-Warning: rray.drdc.mstc.ms.gov: rray owned process doing -bs Date: Fri, 31 Aug 2007 13:32:17 -0500 (CDT) From: Richard Ray X-X-Sender: rray@rray.drdc.mstc.ms.gov To: pgsql-sql@postgresql.org Subject: How to influence the planner Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: ClamAV 0.91.1/4111/Fri Aug 31 10:25:39 2007 on rray.drdc.mstc.ms.gov X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/269 X-Sequence-Number: 29207 I have a table, t1, with about 12 million rows The column foo is unique and indexed The column bar is not unique and is indexed "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 My simple solution is "select * into t2 from t1 where length(bar) = 0;" and "select * from t2 order by foo ;" Is there a way to make "select * from t1 where length(bar) = 0 order by foo ;" or something similar work Thanks Richard Ray