Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 187549FB771 for ; Mon, 7 May 2007 07:58:39 -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 20342-07 for ; Mon, 7 May 2007 07:58:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 213BC9FB76B for ; Mon, 7 May 2007 07:58:36 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1Hl0vL-00011r-0b for pgsql-sql@postgresql.org; Mon, 07 May 2007 06:58:35 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 8AC6E404E; Mon, 7 May 2007 06:58:29 -0400 (EDT) Date: Mon, 7 May 2007 06:58:29 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Sequence vs. Index Scan Message-ID: <20070507105829.GB30076@phlogiston.dyndns.org> References: <29507.1178410970@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/42 X-Sequence-Number: 28323 On Sun, May 06, 2007 at 01:45:54PM -0500, Aaron Bono wrote: > Then I inserted 150 more records in the slow schema and pow - it started > working like the fast schema. > > So my conclusion is that the function is being treated as volatile even > though it is stable because the number of records is small. I don't think that's the issue. If this is dependent on the number of records, then for some reason the way the data is structured means that the planner thinks a seqscan's a better bet. This is probably due to distribution of the values. You could try increasing the stats sample, and see if that helps. A -- Andrew Sullivan | ajs@crankycanuck.ca This work was visionary and imaginative, and goes to show that visionary and imaginative work need not end up well. --Dennis Ritchie