Re: type cast in index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Chris Spotts" <rfusca(at)gmail(dot)com>
Cc: "'Linos'" <info(at)linos(dot)es>, pgsql-general(at)postgresql(dot)org
Subject: Re: type cast in index
Date: 2009-06-09 17:59:11
Message-ID: 23693.1244570351@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Chris Spotts" <rfusca(at)gmail(dot)com> writes:
>> CREATE INDEX fecha_creacion_ordtrab ON orden_trabajo_cabecera USING btree
>> ((time_stamp_creacion::date));
>>
>> but in my postgresql 8.3 version i get this error:
>>
>> ERROR: functions in index expression must be marked IMMUTABLE

> If your time_stamp_creacion is a timestamp with time zone I
> believe that the cast is not immutable.

Precisely, because it depends on the value of the TimeZone setting.

I believe that you could build an index on an expression along the lines
of
(time_stamp_creacion AT TIME ZONE 'UTC')::date
or whatever other time zone you wanted to specify. Whether this'd be
very useful is another question ... I'm afraid you'd have to write the
exact same expression in any query you hoped would use the index.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Linos 2009-06-09 18:01:00 Re: type cast in index
Previous Message Alvaro Herrera 2009-06-09 17:58:57 Re: type cast in index