From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Brian Knox <laotse(at)aol(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Strange Postgresql Indexing Behavior |
Date: | 2002-03-14 02:16:31 |
Message-ID: | 20020314131631.A3954@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
On Wed, Mar 13, 2002 at 04:28:00PM -0500, Brian Knox wrote:
>
> I'm having an interesting time trying to figure out some behavior with
> postgresql indexes that I am trying to understand.
[snip]
> I did more queries and confirmed that when the number of rows returned is
> below a certain number (I don't have enough data to determine the exact
> number) the index is used, and when it is above a certain number, it is
> not used.
>
> Can anyone explain to me what is happening / why it is happening / how to
> make the indexes work correctly?
Well, checking a tuple from an index is more expensive than checking a tuple
from a sequential scan. So, if you want to select 50% of the table, it's
faster to read the whole table than it is to use the index.
The planner tries to guess where the break-even point is. Above, seq scan,
below index scan.
This is a FAQ, IIRC.
HTH,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org>
http://svana.org/kleptog/
> 11/9/2001 - a new beginning or the beginning of the end?
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2002-03-14 02:21:50 | Re: Last Insert |
Previous Message | ljb | 2002-03-14 01:34:57 | Re: Connection handling of Postgre under PHP |
From | Date | Subject | |
---|---|---|---|
Next Message | Bhuvan A | 2002-03-14 05:40:35 | checking for existence of a table in plpgsql. |
Previous Message | Herbert Rabago Ambos | 2002-03-14 02:09:32 | Re: [INIMSS] How to use OID? |