Re: why am I getting a seq scan on this query?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: why am I getting a seq scan on this query?
Дата
Msg-id 23030.1136583816@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: why am I getting a seq scan on this query?  ("Joshua D. Drake" <jd@commandprompt.com>)
Список pgsql-general
"Joshua D. Drake" <jd@commandprompt.com> writes:
> Someone might have a better idea but my guess is that PG things the
> seq_scan would be faster.

That's what it thinks, and it might be right.  This query is fetching 2%
of the table, which is near the crossover point where a seqscan is
faster, assuming that the rows aren't very wide and the target rows are
fairly randomly distributed through the table's pages.

> You could try decreasing your random_page_cost.

First thing to do is force the plan choice (set enable_seqscan = off)
and see what timings you actually get each way.  If the planner really
is guessing materially wrong, then adjusting the cost parameters is
called for.  Don't set them on the basis of a single test case though...

BTW, the bitmap indexscan method available in PG 8.1 can do a lot better
than plain indexscan for scenarios like this, so updating to 8.1 might
be a good answer too.

            regards, tom lane

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

Предыдущее
От: Scott Ribe
Дата:
Сообщение: Re: Reordering columns in a table
Следующее
От: Reid Thompson
Дата:
Сообщение: Flagging and/or Cleansing/Correcting bad telephone number data