Re: [ADMIN] creating index with a cast statement in the predicate

Поиск
Список
Период
Сортировка
От 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 по дате отправления:

Предыдущее
От: Mark Steben
Дата:
Сообщение: [ADMIN] creating index with a cast statement in the predicate
Следующее
От: Dhandapani Shanmugam
Дата:
Сообщение: [ADMIN] native connector to Postgres