Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id B700C47736B for ; Wed, 13 Mar 2002 14:42:04 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 18AACD5F7; Wed, 13 Mar 2002 11:42:05 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 0A2565BFD; Wed, 13 Mar 2002 11:42:05 -0800 (PST) Date: Wed, 13 Mar 2002 11:42:05 -0800 (PST) From: Stephan Szabo To: Nick Fankhauser Cc: pgsql-admin Subject: Re: Optimizing a condition based on an a very unequally In-Reply-To: Message-ID: <20020313113933.M85167-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200203/189 X-Sequence-Number: 3723 On Wed, 13 Mar 2002, Nick Fankhauser wrote: > So my question in general is why does PGSQL opt to use the index when > looking for the single field row, and not use it when looking for the other > 23768 rows? Because in many cases the sequence scan will be faster than an index scan when you're trying to get most of the rows of the table. Since the tuple validity is in the table row and not the index, it's still got to check the table which would involve lots of random reads into that file, so you're doing even more disk operations and less efficient ones.