X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C52F05E46EE for ; Mon, 30 Aug 2004 17:36:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34279-04 for ; Mon, 30 Aug 2004 20:36:35 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 828575E3632 for ; Mon, 30 Aug 2004 17:36:34 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1C1stC-0003Mx-00; Mon, 30 Aug 2004 16:36:30 -0400 To: Martin Sarsale Cc: pgsql-performance@postgresql.org Subject: Re: seqscan instead of index scan References: <6EE64EF3AB31D5448D0007DD34EEB3412A748D@Herge.rcsinc.local> <1093889849.1680.83.camel@kadaif> In-Reply-To: <1093889849.1680.83.camel@kadaif> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 30 Aug 2004 16:36:30 -0400 Message-ID: <873c24ics1.fsf@stark.xeocode.com> Lines: 17 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/459 X-Sequence-Number: 8095 Another option here is to use a partial index. You can index on some other column -- perhaps the column you want the results ordered by where the where clause is true. Something like: create index t_idx on t (name) where c>0 and d>0; then any select with a matching where clause can use the index: select * from t where c>0 and d>0 order by name Could scan the index and not even have to sort on name. -- greg