cast not IMMUTABLE?

From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: cast not IMMUTABLE?
Date: 2004-05-06 23:37:29
Message-ID: c7ei84$j0e$1@floppy.pyrenet.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-hackers

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 ?

How can I define an index for the query (1) ?

Regards
Gaetano Mendola

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Sam Barnett-Cormack 2004-05-07 00:33:58 Re: cast not IMMUTABLE?
Previous Message Chris Gamache 2004-05-06 16:01:33 Re: Postmaster hogs CPU

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-05-06 23:59:56 Re: COPY command - CSV files
Previous Message Marc G. Fournier 2004-05-06 22:59:55 pgFoundry Open For Business