Re: Strange Postgresql Indexing Behavior
От | Martijn van Oosterhout |
---|---|
Тема | Re: Strange Postgresql Indexing Behavior |
Дата | |
Msg-id | 20020314131631.A3954@svana.org обсуждение исходный текст |
Ответ на | Strange Postgresql Indexing Behavior (Brian Knox <laotse@aol.net>) |
Список | pgsql-general |
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@svana.org> http://svana.org/kleptog/ > 11/9/2001 - a new beginning or the beginning of the end?
В списке pgsql-general по дате отправления: