[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-admin
Subject:    Re: [ADMIN] creating index with a cast statement in the predicate
From:       Tom Lane <tgl () sss ! pgh ! pa ! us>
Date:       2017-07-31 18:12:13
Message-ID: 7027.1501524733 () sss ! pgh ! pa ! us
[Download RAW message or body]

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


-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic