Re: optimizer choosing the wrong index

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: optimizer choosing the wrong index
Дата
Msg-id 5911.1278512405@sss.pgh.pa.us
обсуждение исходный текст
Ответ на optimizer choosing the wrong index  (Martin Below <machtin.below@googlemail.com>)
Список pgsql-general
Martin Below <machtin.below@googlemail.com> writes:
> Why is "idx_wrong" used (which only includes one of the fields
> queried) instead of idx_correct (which contains both fields)?

It's not immediately clear that that choice is "wrong".  A two-column
index is bigger and hence more expensive to search than a one-column
index --- perhaps quite substantially so, given this particular
combination of datatypes.  The planner is probably estimating that
the expires_on condition is selective enough that nothing much will be
gained by using the two-column index.  If that's wrong (which is not
proven by your example) you might be able to fix it by increasing
the stats target for the table.  Also, if you haven't customized
effective_cache_size, increasing that makes large indexes look
cheaper to use.

            regards, tom lane

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

Предыдущее
От: Vick Khera
Дата:
Сообщение: Re: Want to schedule tasks for the future
Следующее
От: Andy Colson
Дата:
Сообщение: Re: make view with union return one record