Re: date_trunc'd timestamp index possible?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "D(dot) Duccini" <duccini(at)backpack(dot)com>
Cc: Bruno Wolff III <bruno(at)wolff(dot)to>, pgsql-sql(at)postgresql(dot)org, Pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: date_trunc'd timestamp index possible?
Date: 2004-10-01 21:17:28
Message-ID: 15053.1096665448@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice pgsql-sql

"D. Duccini" <duccini(at)backpack(dot)com> writes:
> I think we found a way around it!

> CREATE OR REPLACE FUNCTION date_immutable( timestamptz ) RETURNS date AS
> 'SELECT date( $1 ) ;' LANGUAGE 'sql' IMMUTABLE ;

No, you just found a way to corrupt your index. Pretending that
date(timestamptz) is immutable does not make it so. The above
*will* break the first time someone uses the table with a different
timezone setting.

What you can do safely is date(footime AT TIME ZONE 'something'),
since this nails down the zone in which the date is interpreted.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kris Kiger 2004-10-01 22:01:48 Re: tsearch2 poor performance
Previous Message Tom Lane 2004-10-01 21:04:50 Re: pg_stat_activity EXISTS bug in 8.0.0beta3

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-10-01 22:53:03 Mislabeled timestamp functions (was Re: [SQL] [NOVICE] date_trunc'd timestamp index possible?)
Previous Message Tom Lane 2004-10-01 18:52:46 Re: max_connections not changing

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-10-01 22:53:03 Mislabeled timestamp functions (was Re: [SQL] [NOVICE] date_trunc'd timestamp index possible?)
Previous Message Tom Lane 2004-10-01 18:49:34 Re: [SQL] date_trunc'd timestamp index possible?