Re: Query not using index, please explain.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Query not using index, please explain.
Дата
Msg-id 29777.984082783@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Query not using index, please explain.  (Matthew Hagerty <mhagerty@voyager.net>)
Список pgsql-hackers
Matthew Hagerty <mhagerty@voyager.net> writes:
> The query where the time_stamp < '03-01-2000' does not return any rows, the 
> 04-01-2000 date does return rows.  When I disable seqscan the query is 
> almost instant, but with it on, it takes about 3 or 4 minutes.  Why can't 
> the query planner use the index in the later case?

It *can* (and did, in two of the three examples you gave).  It just
doesn't think the indexscan is faster --- note the cost estimates.
Evidently the cost estimates are way off, probably because the estimated
number of selected rows is way off.

Have you done a VACUUM ANALYZE lately?  Not that that will help if the
distribution of timestamps is highly irregular :-(.  See the many past
discussions of these issues.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Checkpoint process signal handling seems wrong
Следующее
От: Richard Poole
Дата:
Сообщение: Re: Query not using index, please explain.