Re: [8.1.4] Create index on timestamp fails

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Arturo Perez <aperez(at)hayesinc(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: [8.1.4] Create index on timestamp fails
Date: 2006-08-23 13:07:35
Message-ID: 20060823130735.GC1963@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

> >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.
>
> 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.

Another idea would be to separate the date column (which would have the
index) from the time column (which would have the timezone). The
timezone is important -- if you have "bloggers" from all around the
world you're gonna have serious problems with the archived time.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Page 2006-08-23 13:10:42 Re: What's special about 1916-10-01 02:25:20? Odd jump in internal timestamptz representation
Previous Message Roman Neuhauser 2006-08-23 13:05:35 Re: UUID as primary key