Re: Doesn't use index, why?

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Doesn't use index, why?
Дата
Msg-id 200101090609.BAA26593@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: Doesn't use index, why?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
> In this case the planner is doing *exactly* the right thing; it is
> smarter than you are.  If you want to prove it, force the planner to
> use an indexscan by doing SET ENABLE_SEQSCAN TO OFF.  Then time the
> query, and compare the runtime against the seqscan version.
>
> The bottom line here is that a query that needs to touch more than a
> few percent of the rows in a table is better off being done as a
> seqscan.

The only other workaround is to CLUSTER the table on an index, then
force an index scan.  That _may_ be faster.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

В списке pgsql-general по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: 7.1 PL/pgSQL EXECUTE Command
Следующее
От: Tom Lane
Дата:
Сообщение: Re: WAL questions