Re: index not always used when selecting on a date field
В списке pgsql-general по дате отправления:
| От | Greg Stark |
|---|---|
| Тема | Re: index not always used when selecting on a date field |
| Дата | |
| Msg-id | 87mzxsjgo4.fsf@stark.xeocode.com обсуждение исходный текст |
| Ответ на | Re: index not always used when selecting on a date field (Russell Smith <mr-russ@pws.com.au>) |
| Список | pgsql-general |
Russell Smith <mr-russ@pws.com.au> writes: > now() and CURRENT_DATE, are and cannot be planned as constants. > So the planner cannot use an index for them. It's not that it cannot use an index, but that it doesn't know it should use an index. The planner knows that it can't count on now() to be constant so it doesn't use the value it has. As far as it's concerned you're comparing against an unknown value. And in general the postgres optimizer assumes single sided inequalities with unknown constants aren't selective enough to justify an index scan. The easiest work-around is probably just putting in a bogus second inequality to make it a range. The planner generally assumes ranges are selective enough to justify index scans. -- greg
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера