Re: index compatible date_trunc in postgres?

From: Bryce Nesbitt <bryce2(at)obviously(dot)com>
To: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: index compatible date_trunc in postgres?
Date: 2008-12-19 18:15:37
Message-ID: 494BE4C9.7020607@obviously.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom Lane wrote:
> Why are you worrying? The old method surely didn't get indexed either.

Continuous improvement?

Since there already IS an index available, I figure I might as well use
it, especially since this DB had real performance issues. The table
itself is medium sized in our world, at 647596 rows.

Scott Marlowe wrote:
> You can create an index on date_trunc (on timestamp without timezone,
> but not on timestamp with timezone since it's not immutable)
That could work...
create index brycetest5 on contexts (date_trunc('month',publication_date));
(13 MB index, same size as the index on the non-truncated date).

Unfortunately complains about immutability:
create index brycetest5 on contexts (to_char(publication_date,'YYYY-MM'));

But in this case I think I'll rewrite the query into a range, and stick
with the present index.
Thanks for your help.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Mahmoud Ewiwi 2008-12-19 20:42:59 Invitation to connect on LinkedIn
Previous Message Tom Lane 2008-12-19 14:03:36 Re: Downgrade database and problem with sequences