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 B6A105E46CC for ; Mon, 30 Aug 2004 17:04:09 -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 22342-05 for ; Mon, 30 Aug 2004 20:04:02 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id DB7A95E46C1 for ; Mon, 30 Aug 2004 17:04:01 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id E684B3504A; Mon, 30 Aug 2004 13:04:00 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id E51F135017; Mon, 30 Aug 2004 13:04:00 -0700 (PDT) Date: Mon, 30 Aug 2004 13:04:00 -0700 (PDT) From: Stephan Szabo To: Martin Sarsale Cc: pgsql-performance@postgresql.org Subject: Re: seqscan instead of index scan In-Reply-To: <1093889849.1680.83.camel@kadaif> Message-ID: <20040830130016.T98089@megazone.bigpanda.com> References: <6EE64EF3AB31D5448D0007DD34EEB3412A748D@Herge.rcsinc.local> <1093889849.1680.83.camel@kadaif> 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/457 X-Sequence-Number: 8093 On Mon, 30 Aug 2004, Martin Sarsale wrote: > On Mon, 2004-08-30 at 15:06, Merlin Moncure wrote: > > create function is_somethingable (ctype, dtype) returns boolean as > > Thanks, but I would prefer a simpler solution. > > I would like to know why this uses a seqscan instead of an index scan: > > create index t_idx on t((c+d)); > select * from t where c+d > 0; As a geuss, since 7.4 and earlier have no statistics on the distribution of c+d it has to guess about how likely that is to be true and is probably overestimating. 8.0beta might handle this better.