Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id ECDC29FA508 for ; Sat, 5 May 2007 21:41:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 09859-09 for ; Sat, 5 May 2007 21:40:55 -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 137289FA4F0 for ; Sat, 5 May 2007 21:40:59 -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 1HkUo6-00029O-Mj for pgsql-sql@postgresql.org; Sat, 05 May 2007 20:40:58 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 42A844050; Sat, 5 May 2007 20:40:53 -0400 (EDT) Date: Sat, 5 May 2007 20:40:53 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Sequence vs. Index Scan Message-ID: <20070506004053.GA22890@phlogiston.dyndns.org> References: <20070505213009.GA22573@phlogiston.dyndns.org> 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/29 X-Sequence-Number: 28310 On Sat, May 05, 2007 at 05:00:53PM -0500, Aaron Bono wrote: > > They have different data. The fast one has about 150 rows and the slow one > has about 40 rows. The field in question here, the branch_id, is a > BIGSERIAL in both. I'd be astonished if a table of 40 rows ever got index scanned. It's probably more efficient to read the whole table. But it seems your case may be strange. > We don't allow deletes and updates are fairly infrequent. I also did a > vacuum analyze to no effect. How do you "not allow" deletes? Does this happen because of a failed foreign key? If so, you can end up with dead tuples. I'd look at the output of VACUUM VERBOSE to make sure you don't have a lot of dead tuples. That said, I wonder if fiddling with the statistics on your tables might help. A -- Andrew Sullivan | ajs@crankycanuck.ca In the future this spectacle of the middle classes shocking the avant- garde will probably become the textbook definition of Postmodernism. --Brad Holland