| От | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера