Re: [8.1.4] Create index on timestamp fails

From: Arturo Perez <aperez(at)hayesinc(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [8.1.4] Create index on timestamp fails
Date: 2006-08-23 00:35:41
Message-ID: B4D42863-7FBF-4A9E-8D97-952245384485@hayesinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Aug 22, 2006, at 5:35 PM, Tom Lane wrote:

> "Arturo Perez" <aperez(at)hayesinc(dot)com> writes:
>> I have a table with an column:
>> entry_date | timestamp with time zone| not null
>
>> And when I try to create an index on it like so:
>> create index entry_date_idx on =
>> user_tracking(date_part('year',entry_date));
>
>> I get a
>> ERROR: functions in index expression must be marked IMMUTABLE
>
>> According to the mailing lists, this has been working since 7.4.
>
> I seriously doubt that. date_part on a timestamptz is stable, not
> immutable, and AFAICT has been marked that way since 7.3. The problem
> is that the results depend on your current TimeZone setting --- for
> instance, 2AM 2006-01-01 in London is 9PM 2005-12-31 where I live.
>
> If you only need day precision, try storing entry_date as a date
> instead
> of a timestamptz. Or perhaps consider timestamp without tz. But you
> need something that's not timezone-dependent to make this work.
>
> regards, tom lane

Ah, I knew it was something I was overlooking. Thanks a ton. We need
sub-day granularity (it's for a sort of weblog). Without a TZ sounds
llke
a winner.

Thanks again,
arturo

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message nuno 2006-08-23 00:43:29 Re: error msg when pg_restore
Previous Message Michael Fuhr 2006-08-23 00:25:25 Re: trigger help