From: Nick Fankhauser <nickf@ontko.com>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: Optimizing a condition based on an a very unequally distributed value.
Date: Wed, 13 Mar 2002 14:47:42 -0500
Message-ID: <NEBBLAAHGLEEPCGOBHDGEENMEIAA.nickf@ontko.com> (raw)
In-Reply-To: <20020313113933.M85167-100000@megazone23.bigpanda.com>
Thanks for the answer! ...but now I have more questions:
Is it true that if I use this condition in a join that further constrains
the results, this might use the index?
Does PGSQL know that few or many rows will be returned because of data
gathered from the last vacuum?
What do you mean by "tuple validity?" can't this query be resolved entirely
based on the index?
-Nick
> -----Original Message Snips:-----
> > 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.
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: nickf@ontko.com, sszabo@megazone23.bigpanda.com
Subject: Re: Optimizing a condition based on an a very unequally distributed value.
In-Reply-To: <NEBBLAAHGLEEPCGOBHDGEENMEIAA.nickf@ontko.com>
References: <20020313113933.M85167-100000@megazone23.bigpanda.com> <NEBBLAAHGLEEPCGOBHDGEENMEIAA.nickf@ontko.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox