Re: creating index with a cast statement in the predicate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Steben <mark.steben@xxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux