Re: [ADMIN] creating index with a cast statement in the predicate
В списке pgsql-admin по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: [ADMIN] creating index with a cast statement in the predicate |
| Дата | |
| Msg-id | 7027.1501524733@sss.pgh.pa.us обсуждение |
| Ответ на | [ADMIN] creating index with a cast statement in the predicate (Mark Steben <mark.steben@drivedominion.com>) |
| Список | pgsql-admin |
Mark Steben <mark.steben@drivedominion.com> writes:
> I would like to create an index on a column named value: defined as
> varchar(255)
> Values in this column can be many, including both dates and non-dates.
> The developers run a query that first uses a regular expression to filter
> non-dates out
> then, ANDS it with the following
> *and cast(value as date) >= date_trunc('MONTH', current_date) - interval '
> 2 Month '*
> When I attempt to create an index using this statement in the
> predicate, I get the error that states that functions in an index predicate
> must be marked as Immutable.
I think it's unhappy about the varchar-to-date cast. That is not
considered immutable because the behavior of date_in() depends on
the setting of DateStyle.
regards, tom lane
В списке pgsql-admin по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера