Re: cast not IMMUTABLE?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Gaetano Mendola <mendola(at)bigfoot(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: cast not IMMUTABLE?
Date: 2004-05-08 23:33:51
Message-ID: 20040508162937.S66447@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-hackers


On Fri, 7 May 2004, Gaetano Mendola wrote:

> Hi all,
> I have a table with ~ 3e+6 rows on it.
>
> I do select on this table in this way:
>
>
> (1) select * from user_logs where login_time::date = now()::date;
>
>
> consider that login_time is a TIMESTAMPTZ with an index on it.
>
> If I use the select in this way:
>
> select * from user_logs where login_time = now();
>
> the the index is used.
>
> I'm trying to use define and index in order to help the query (1):
>
>
> test# create index idx on user_logs ( (login_time::date) );
> ERROR: functions in index expression must be marked IMMUTABLE
>
>
> why that cast is not considered IMMUTABLE ?

I'd think the conversion of a timestamptz -> date would be dependent on
timezone which would make it not immutable.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Armel HERVE 2004-05-10 10:20:31 User defined type in C
Previous Message Jim Seymour 2004-05-07 22:06:44 Re: FW: Help installing pgSQL 7.4.2 on Solaris 9

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2004-05-09 01:45:12 Re: Comments on all system objects
Previous Message Bruce Momjian 2004-05-08 23:30:39 Re: Relocatable installs