Re: how to enforce index sub-select over filter+seqscan

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: how to enforce index sub-select over filter+seqscan
Дата
Msg-id 4C9B2F570200002500035C00@gw.wicourts.gov
обсуждение исходный текст
Ответ на how to enforce index sub-select over filter+seqscan  (Dmitry Teslenko <dteslenko@gmail.com>)
Список pgsql-performance
Dmitry Teslenko <dteslenko@gmail.com> wrote:

> Seqscan is very slow and I want to avoid it. Subquery is very fast
> and i don't know why postgres chooses that plan.
>
> I know I can set enable_seqscan = off.
> Is there other ways to enforce index usage?

If you come at it from that angle, you probably won't get the best
resolution.  PostgreSQL can see the alternative plans, and develops
estimated costs of running each.  It uses the one that it thinks
will be fastest.  If it's wrong, there's probably something wrong
with the statistics it uses for estimating, or with the costing
information.  (There are some cases where it's not able to
accurately estimate costs even if these are right, but let's check
the more common cases first.)

Please provide a little more information, like PostgreSQL version,
the postgresql.conf contents (excluding comments), OS, hardware, and
the EXPLAIN ANALYZE output of the query with and without
enable_seqscan = off.

Other useful ideas here:

http://wiki.postgresql.org/wiki/SlowQueryQuestions

-Kevin

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

Предыдущее
От: Dmitry Teslenko
Дата:
Сообщение: how to enforce index sub-select over filter+seqscan
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: Useless sort by