Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 50BB547607C for ; Wed, 29 May 2002 13:21:37 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id C328F4758E6 for ; Wed, 29 May 2002 13:18:54 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 3AFB5D5FA; Wed, 29 May 2002 10:18:53 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 1A6025C01; Wed, 29 May 2002 10:18:53 -0700 (PDT) Date: Wed, 29 May 2002 10:18:52 -0700 (PDT) From: Stephan Szabo To: Wei Weng Cc: Subject: Re: Can you help with this JOIN? In-Reply-To: <1022689283.26718.9.camel@Monet> Message-ID: <20020529100354.M33333-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200205/308 X-Sequence-Number: 7943 On 29 May 2002, Wei Weng wrote: > One question is: It appears to be using Sequential scan on tables no > matter how big it is. I tried to set enable_seqscan='false' and then > vacuum analyze, but the result is even worse. > > Isn't index scan supposed to be faster/better than sequential scan for > large tables? One table (contentsummaries) has 11000 entries and another Not necessarily. If the values in the table are in random pages (ie, no real coordination between index key value and position in table) after a point you end up reading most of the pages of the table anyway, plus you're reading the index (and the smaller the individual row, the more likely this is to occur as well I'd guess) You might want to consider trying other join orders since you're using explicit join syntax since postgres will take the order you're doing your joins as the order you want the joins to be done in. And are you sure you need the distinct, that's probably resulting in the sort and unique step. For other things, what are your postgresql.conf settings for shared memory and sort memory?